Re: [R] Data frames, passing by value, and performance

2010-05-24 Thread Gabor Grothendieck
If you don't modify the data frame in your function it won't physically make a new copy. On Mon, May 24, 2010 at 10:29 AM, wrote: > I understand that everything passed to an R function is passed "by > value".  This would seem to include data frames, which my current > application uses heavily, b

[R] Data frames, passing by value, and performance

2010-05-24 Thread gschultz
I understand that everything passed to an R function is passed "by value". This would seem to include data frames, which my current application uses heavily, both for storing program inputs, and holding intermediate and final results. In trying to get greater performance out of my R code, I am wo

Re: [R] Data reconstruction following PCA using Eigen function

2010-05-22 Thread Thomas Stewart
Looks like you have some numerical precision issues. Why not use the svd function directly? (See below.) -tgs x <- read.table( textConnection( "Sample1 0.7329881 0.76912670 2.45906143 -0.06411602 1.2427801 0.3785717 2.34508664 1.1043552 -0.1883830 0.6503095 Sample2 -2.0446131 1.727832

[R] Data reconstruction following PCA using Eigen function

2010-05-21 Thread Julia El-Sayed Moustafa
Hi all, As a molecular biologist by training, I'm fairly new to R (and statistics!), and was hoping for some advice. First of all, I'd like to apologise if my question is more methodological rather than relating to a specific R function. I've done my best to search both in the forum and elsewhere

[R] Data preparation for MCMCbinaryChange

2010-05-17 Thread Shige Song
Dear All, Since no one has answered my previous question, let me revise it a little and ask again. My data set contains about 10,000 women born in 60 months. The outcome variable is a binary variable indicating whether one has certain health problems. My hypothesis is that the 60 months in which

Re: [R] Data Mining Survey

2010-05-12 Thread Muenchen, Robert A (Bob)
t;On Behalf Of Muenchen, Robert A (Bob) >Sent: Wednesday, May 12, 2010 8:54 AM >To: r-help@r-project.org >Subject: [R] Data Mining Survey > >Dear R-Helpers, > >SAS Institute just mailed out the notice below regarding a survey of >people who do data mining. To help keep t

Re: [R] Data Mining Survey

2010-05-12 Thread Muenchen, Robert A (Bob)
chen, Robert A (Bob) >Sent: Wednesday, May 12, 2010 8:54 AM >To: r-help@r-project.org >Subject: [R] Data Mining Survey > >Dear R-Helpers, > >SAS Institute just mailed out the notice below regarding a survey of >people who do data mining. To help keep the survey from becoming

Re: [R] data frame subscription

2010-05-12 Thread David Winsemius
"STANDARD LEAD USD"), class = "factor"), POSITION = c(2, -3, -2, -2, -18, -3, -5, 1, -5, 1), prix = c(-702.9, 244.77, 166.48, 2273.8, 24876, 2985, 80.9, -15.95, 2512.5, -2423)), .Names = c("DESCRIPTION", "POSITION", "prix"), row.names = c

Re: [R] data frame subscription

2010-05-12 Thread arnaud Gaboury
TY. Didn't know this function. From: Henrique Dallazuanna [mailto:www...@gmail.com] Sent: Wednesday, May 12, 2010 3:32 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame subscription Try this: transform(pose16, prix = POSITION * SETTLEMENT, SETTLEMENT =

Re: [R] data frame subscription

2010-05-12 Thread arnaud Gaboury
M HGH GD ALUMINIUM USD", "SPCL HIGH GRADE ZINC USD", "STANDARD LEAD USD"), class = "factor"), POSITION = c(2, -3, -2, -2, -18, -3, -5, 1, -5, 1), prix = c(-702.9, 244.77, 166.48, 2273.8, 24876, 2985, 80.9, -15.95, 2512.5, -2423)), .Names = c("DES

Re: [R] data frame subscription

2010-05-12 Thread arnaud Gaboury
> Cc: arnaud Gaboury; r-help@r-project.org > Subject: Re: [R] data frame subscription > > Couldn't you just put a minus sign in from of the derived "prix" > expression? > > transform(pose16, prix = - POSITION * SETTLEMENT, SETTLEMENT = NULL, > POSITION > = POSI

Re: [R] data frame subscription

2010-05-12 Thread Henrique Dallazuanna
GAR NO.11 May/10", > "WHEAT Jul/10", "PRIMARY NICKEL USD", "PRM HGH GD ALUMINIUM USD", > "SPCL HIGH GRADE ZINC USD", "STANDARD LEAD USD"), class = "factor"), > POSITION = c(2, -3, -2, -2, -18, -3, -5, 1, -5, 1), prix = c(-702.

Re: [R] data frame subscription

2010-05-12 Thread Henrique Dallazuanna
Try this: transform(pose16, prix = POSITION * SETTLEMENT, SETTLEMENT = NULL, POSITION = POSITION * -1) On Wed, May 12, 2010 at 9:50 AM, arnaud Gaboury wrote: > Dear group, > > Here is my df : > > pose16 <- > structure(list(DESCRIPTION = structure(c(1L, 2L, 3L, 4L, 5L, > 6L, 7L, 8L, 9L, 12L), .L

[R] data frame subscription

2010-05-12 Thread arnaud Gaboury
Dear group, Here is my df : pose16 <- structure(list(DESCRIPTION = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 12L), .Label = c("COPPER May/10", "COTTON NO.2 Jul/10", "CRUDE OIL miNY May/10", "GOLD Jun/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11

[R] Data Mining Survey

2010-05-12 Thread Muenchen, Robert A (Bob)
Dear R-Helpers, SAS Institute just mailed out the notice below regarding a survey of people who do data mining. To help keep the survey from becoming biased toward commercial software, I thought it would be good to post it here as well. Cheers, Bob Fourth Annual Data Miner Survey Rexer Analytics

[R] R: Data frame "pivoting"

2010-05-06 Thread ANGELO.LINARDI
It works perfectly !!! Thank you so much !! Angelo -Messaggio originale- Da: Patrick Hausmann [mailto:patrick.hausm...@uni-bremen.de] Inviato: giovedì 6 maggio 2010 12.05 A: LINARDI ANGELO Cc: r-help@r-project.org Oggetto: Re: [R] Data frame "pivoting" Hi Angelo, try x &l

Re: [R] Data frame "pivoting"

2010-05-06 Thread Patrick Hausmann
Hi Angelo, try x <- structure(list(ID = c("A1", "A1", "A1", "A1", "A1", "A2", "A2", "A3", "A3", "A3", "A3", "A3"), YEAR = c(2007, 2007, 2007, 2008, 2008, 2007, 2008, 2007, 2007, 2008, 2008, 2008), PROPERTY = c("P1", "P2", "P3", "P1", "P2", "P5", "P6", "P1", "P3", "P1", "P2", "P6" ), VALUE = c(1,

Re: [R] Data frame "pivoting"

2010-05-06 Thread Tal Galili
Hi Angelo, You can solve thins using the "melt" and "cast" functions in the "reshape" package. Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.

[R] Data frame "pivoting"

2010-05-06 Thread ANGELO.LINARDI
Dear R experts, I am trying to solve this problem, related to the possibility of changing the shape of a data frame using a "pivoting-like" function. I have a dataframe df of observations as follows: ID VALIDITY YEAR PROPERTYPROPERTY VALUE A1 2007

Re: [R] data frame move columns

2010-04-28 Thread arnaud Gaboury
TY david. Here we go with a correct code! > -Original Message- > From: David Winsemius [mailto:dwinsem...@comcast.net] > Sent: Wednesday, April 28, 2010 5:28 PM > To: arnaud Gaboury > Cc: r-help@r-project.org > Subject: Re: [R] data frame move columns > > >

Re: [R] data frame move columns

2010-04-28 Thread arnaud Gaboury
I want the 0s to be at the end or beginning. > -Original Message- > From: Erik Iverson [mailto:er...@ccbr.umn.edu] > Sent: Wednesday, April 28, 2010 5:21 PM > To: arnaud Gaboury > Cc: r-help@r-project.org > Subject: Re: [R] data frame move columns > > > >

Re: [R] data frame move columns

2010-04-28 Thread David Winsemius
On Apr 28, 2010, at 11:14 AM, arnaud Gaboury wrote: Dear group, Here is my df: avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD", "STANDARD LEAD USD"), prix = c(-1.5, -1082, 11084, 1983.5, -24

Re: [R] data frame move columns

2010-04-28 Thread Erik Iverson
avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD", "STANDARD LEAD USD"), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8, 2, -1, 0), fees = c(-8.64, -30.24, -26.4, -25.9

[R] data frame move columns

2010-04-28 Thread arnaud Gaboury
Dear group, Here is my df: avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD", "STANDARD LEAD USD"), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8, 2, -1, 0), fees = c(-8.

Re: [R] data frame manipulation and regex

2010-04-28 Thread David Winsemius
0""ROBUSTA COFFEE (10) Jul/10" [4] "SOYBEANS Jul/10""SPCL HIGH GRADE ZINC USD\n" "STANDARD LEAD USD " -- David *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F ******* -Original Messag

Re: [R] data frame manipulation and regex

2010-04-28 Thread Henrique Dallazuanna
gt; > > *** > Arnaud Gaboury > Mobile: +41 79 392 79 56 > BBM: 255B488F > *** > > > > -Original Message- > > From: David Winsemius [mailto:dwinsem...@comcast.net] > > Sent: Wednesday, April 28, 2010 2:25 PM &g

Re: [R] data frame manipulation and regex

2010-04-28 Thread arnaud Gaboury
Winsemius [mailto:dwinsem...@comcast.net] > Sent: Wednesday, April 28, 2010 2:25 PM > To: arnaud Gaboury > Cc: r-help@r-project.org > Subject: Re: [R] data frame manipulation and regex > > > On Apr 28, 2010, at 5:14 AM, arnaud Gaboury wrote: > > > Dear group, > > &g

Re: [R] data frame manipulation and regex

2010-04-28 Thread David Winsemius
On Apr 28, 2010, at 5:14 AM, arnaud Gaboury wrote: Dear group, Here is my data.frame : avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD Jul/10", "STANDARD LEAD USD Jul/10"), prix = c(-1.5, -108

[R] data frame manipulation and regex

2010-04-28 Thread arnaud Gaboury
Dear group, Here is my data.frame : avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD Jul/10", "STANDARD LEAD USD Jul/10"), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8,

Re: [R] data frame

2010-04-27 Thread Ista Zahn
Here is one way, using the reshape package: library(reshape) Dat <- read.table(textConnection("variable YEAR VAR EC01 2006 100 EC01 2007 200 EC02 2006 500 EC02 2007 450 PROD 2006 567 PROD 2007 543"), header=TRUE) closeAllConnections() c.Dat1 <- as.data.frame(cast(Dat, YEAR ~ variable, value = "

[R] data frame

2010-04-27 Thread n.via...@libero.it
Dear list, I have a big data frame which looks like this: variable YEAR VAR EC01 2006 100 EC01 2007 200 EC02 2006

Re: [R] data frame

2010-04-26 Thread jim holtman
Is this what you want: > x <- read.table(textConnection("variable YEAR VAR + EC01 2006 100 + + EC01 2007 200 + + EC02 2006 5

Re: [R] data frame

2010-04-26 Thread Tal Galili
you can do this: a <- tapply(VAR, YEAR, prod) The use "merge" to create a new variable of the length of your original VAR, and just do VAR/prod.VAR Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read m

Re: [R] data frame

2010-04-26 Thread Henrique Dallazuanna
Try this: sweep(with(x, tapply(VAR, list(variable, YEAR), FUN = prod)), 2, with(x, tapply(VAR, YEAR, FUN = prod)), FUN = "/") On Mon, Apr 26, 2010 at 12:07 PM, n.via...@libero.it wrote: > > Dear list, > I have a big data frame which looks like this: > variable YEAR

[R] data frame

2010-04-26 Thread n.via...@libero.it
Dear list, I have a big data frame which looks like this: variable YEAR VAR EC01 2006 100 EC01 2007 200 EC02 2006

Re: [R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
Excellent!! You saved me hours and hours of turning around and around. TY so much. From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Friday, April 16, 2010 1:37 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation It works for me... > DF <- + str

Re: [R] data frame manipulation

2010-04-16 Thread Ista Zahn
, arnaud Gaboury wrote: > When I pass your command line, here is what I get : > > > >op=ddply(df,c("DESCRIPTION"),summarise,POSITION=sum(QUANITY),DATE=max(CREAT > ED.DATE),SETTLEMENT=CLOSING.PRICE[CREATED.DATE=max(CREATED.DATE)]) > > op > > DESCRIPTION POSITION

Re: [R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
the CREATED.DATE *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F *** From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Friday, April 16, 2010 1:05 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation Hi, I'm not sure I understand

Re: [R] data frame manipulation

2010-04-16 Thread Ista Zahn
Hi, I'm not sure I understand what you want exactly. My best guess is that you want something like op=ddply(DF, c("DESCRIPTION"), summarise, POSITION= sum(QUANITY),DATE=max(CREATED.DATE), CLOSING.PRICE = CLOSING.PRICE[CREATED.DATE == max(CREATED.DATE)]) op <- unique(op) Does that do it? -Ista

[R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
Dear group, Here is my data.frame : df <- structure(list(DESCRIPTION = c("PRM HGH GD ALU", "PRM HGH GD ALU", "PRIMARY NICKEL", "PRIMARY NICKEL", "PRIMARY NICKEL", "PRIMARY NICKEL", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STA

[R] Data Synchronization -- detecting time differences in multi-source data

2010-04-12 Thread Ralf B
Hi R enthusiasts, I am dealing with logging data from different sources that contain data from user activities. The data is all timelined with one column containing Epoch time and two columns containing data (x and y coordinates of mouse movements) = three columns for each source. I have up to 10

Re: [R] Data manipulation problem

2010-04-09 Thread Dieter Menne
Bert Gunter wrote: > > Yes. Don't do this. > > (what you probably really want to do is fit a model with age as a factor, > which can be done statistically e.g. by logistic regression; or > graphically > using conditioning plots, e.g. via trellis graphics (the lattice package). > This avoids the

Re: [R] Data manipulation problem

2010-04-09 Thread moleps
1002 866 >>>>>> 547 247 82 18 >>>>>>> table (yr5) >>>>>> yr5 >>>>>> (1950,1955] (1955,1960] (1960,1965] (1965,1970] (1970,1975] (1975,1980] >>>>>> (1980,1985] (1985,1990] (1990,1

Re: [R] Data manipulation problem

2010-04-07 Thread David Winsemius
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of moleps Sent: Monday, April 05, 2010 11:46 AM To: r-help@r-project.org Subject: [R] Data manipulation problem Dear R´ers. I´ve got a dataset with age and year of diagnosis. In order to age-standardize the incid

Re: [R] Data manipulation problem

2010-04-07 Thread moleps islon
45] (45,50] (50,55] (55,60] (60,65] (65,70] (70,75] (75,80] >>>>>> (80,85] (85,100] 35 34 33 47 51 109 >>>>>> 157 231 362 511745 926 1002 866 >>>>>>

Re: [R] Data manipulation problem

2010-04-06 Thread David Winsemius
llis graphics (the lattice package). This avoids the arbitrariness and discontinuities of binning by age range.) Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of moleps Sent: Monda

Re: [R] Data manipulation problem

2010-04-06 Thread David Winsemius
istics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of moleps Sent: Monday, April 05, 2010 11:46 AM To: r-help@r-project.org Subject: [R] Data manipulation problem Dear R´ers. I´ve got a dataset with age and year of diagnosis.

Re: [R] Data manipulation problem

2010-04-06 Thread moleps islon
> >>>> Yes. Don't do this. >>>> >>>> (what you probably really want to do is fit a model with age as a factor, >>>> which can be done statistically e.g. by logistic regression; or graphically >>>> using conditioning plots, e.g. via

Re: [R] Data manipulation problem

2010-04-05 Thread moleps
itioning plots, e.g. via trellis graphics (the lattice package). >>> This avoids the arbitrariness and discontinuities of binning by age range.) >>> >>> Bert Gunter >>> Genentech Nonclinical Biostatistics >>> >>> -Original Message- >

Re: [R] Data manipulation problem

2010-04-05 Thread Erik Iverson
f binning by age range.) Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of moleps Sent: Monday, April 05, 2010 11:46 AM To: r-help@r-project.org Subject: [R] Data manipulation problem De

Re: [R] Data manipulation problem

2010-04-05 Thread moleps
kage). > This avoids the arbitrariness and discontinuities of binning by age range.) > > Bert Gunter > Genentech Nonclinical Biostatistics > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of moleps &

Re: [R] Data manipulation problem

2010-04-05 Thread Bert Gunter
onday, April 05, 2010 11:46 AM To: r-help@r-project.org Subject: [R] Data manipulation problem Dear R´ers. I´ve got a dataset with age and year of diagnosis. In order to age-standardize the incidence I need to transform the data into a matrix with age-groups (divided in 5 or 10 years) along one axis a

Re: [R] Data manipulation problem

2010-04-05 Thread Erik Iverson
?cut to create categories ?table to make the table moleps wrote: Dear R´ers. I´ve got a dataset with age and year of diagnosis. In order to age-standardize the incidence I need to transform the data into a matrix with age-groups (divided in 5 or 10 years) along one axis and year divided into 5

[R] Data manipulation problem

2010-04-05 Thread moleps
Dear R´ers. I´ve got a dataset with age and year of diagnosis. In order to age-standardize the incidence I need to transform the data into a matrix with age-groups (divided in 5 or 10 years) along one axis and year divided into 5 years along the other axis. Each cell should contain the number o

[R] export R data as web service

2010-04-01 Thread Johann Hibschman
I'd like to access data in my R session from elsewhere via HTTP. My particular use case would be R on Linux, accessing data from Windows, all on the same intranet. Naively, when I say this, I imagine something like: > theData <- big.calculation.returning.data.frame() > startHttpServer(port=8675)

Re: [R] Data sets with usage in documentation object 'data' but not in the code

2010-03-29 Thread Remko Duursma
It means that in your documentation file (the .Rd file), you have an entry for 'mydata' that does not appear in the code. So: your Rd file has: \usage{ myfunction(mydata,otherarg) } and your function looks like this: myfunction <- function(otherarg,...){etc} good luck, remko -

[R] Data sets with usage in documentation object 'data' but not in the code

2010-03-29 Thread shruti
Hi , I'm getting a warning "Data sets with usage in documentation object 'data' but not in the code" I'm attaching the image for your reference http://n4.nabble.com/file/n1738289/dataset.jpg Thank you -- View this message in context: http://n4.nabble.com/Data-sets-with-usage-in-documentation-

Re: [R] Data sets with usage in documentation object 'data' but not in the code

2010-03-29 Thread Steve Lianoglou
> My Name is shruti.when I was checking a package i got a warning "Data sets > with usage in documentation object 'data' but not in the code" can anyone > help me with this. Can you please provide the exact code you entered into your workspace that gave you this error, so we can reproduce it and h

[R] Data sets with usage in documentation object 'data' but not in the code

2010-03-29 Thread shruti
Hi, My name is shruti,When I was trying to check the package I got this error "Data sets with usage in documentation object 'data' but not in the code" Can any one help me with this. -- View this message in context: http://n4.nabble.com/Data-sets-with-usage-in-documentation-object-data-but-no

[R] Data sets with usage in documentation object 'data' but not in the code

2010-03-29 Thread shruti
Hi, My Name is shruti.when I was checking a package i got a warning "Data sets with usage in documentation object 'data' but not in the code" can anyone help me with this. Thank you -- View this message in context: http://n4.nabble.com/Data-sets-with-usage-in-documentation-object-data-but-not-i

Re: [R] Data sets with usage in documentation object 'data' but not in the code

2010-03-29 Thread David Winsemius
On Mar 29, 2010, at 4:49 PM, shruti wrote: Hi, My name is shruti,When I was trying to check the package I got this error "Data sets with usage in documentation object 'data' but not in the code" Can any one help me with this.I'm attaching the file for your reference http://n4.nabble.com

[R] Data sets with usage in documentation object 'data' but not in the code

2010-03-29 Thread shruti
Hi, My name is shruti,When I was trying to check the package I got this error "Data sets with usage in documentation object 'data' but not in the code" Can any one help me with this.I'm attaching the file for your reference http://n4.nabble.com/file/n1695616/dataset.jpg Thank you -- View this

[R] data fitting and confidence band

2010-03-27 Thread Giovanni Azua Garcia
Hello, I am fitting data using different methods e.g. Local Polynomial and Smoothing splines. The data is generated out of a true function model with added normally distributed noise. I would like to know "how often the confidence band for all points simultaneously contain all true values". I

Re: [R] with data in the form of an R data objecte: Monte Carlo simulation in R

2010-03-24 Thread David Winsemius
0% 50% 60% 50% 0% 10% 20% 0% 20% As Alex Trebeck would say: Can you put that in the form of an R data object? Based on this matrix, I want to locate the persons to zones based on the probability using a Monte Carlo method. The result I want to see is like this: 0 0 0 0 0 0 0 1 1 1

[R] with data in the form of an R data objecte: Monte Carlo simulation in R

2010-03-23 Thread Hongwei Dong
nd each row represents a zone. So, the probability that the >> first >> person will choose the 2nd zone is 30%. >> >> 25% 30% 10% 30% 20% 0% 20% 50% 60% 50% 0% 10% 20% 0% 20% >> > > As Alex Trebeck would say: Can you put that in the form of an R data > objec

Re: [R] Data frame question

2010-03-12 Thread Claudia Beleites
rate Research Laboratory - E-mail: apjawor...@mmm.com Tel: (651) 733-6092 Fax: (651) 736-3122 From: Claudia Beleites To: apjawor...@mmm.com Cc: r-help@r-project.org Date: 03/12/2010 02:13 PM Subject:Re: [R] Data frame question Andy, Did you run into any kind of tro

Re: [R] Data frame question

2010-03-12 Thread Claudia Beleites
Andy, Did you run into any kind of trouble? I'm asking because I'm maintaining a package for spectroscopic data that heavily uses "I (spectra.matrix)" ... However, once you have the matrix safe inside the data.frame, you can delete the "AsIs": > a <- matrix (1:9, 3) > str (a) int [1:3, 1:

[R] Data frame question

2010-03-12 Thread apjaworski
Hi, I have the following question about creating data frames. I want to create a data frame with 2 components: a vector and a matrix. Let me use a simple example: y <- rnorm(10) x <- matrix(rnorm(150), nrow=10) Now if I do dd <- data.frame(x=x, y=y) I get a data frame with 16 colums, but if

Re: [R] data frame select max group by like function

2010-03-09 Thread Tan, Richard
Thanks all for the help! -Original Message- From: William Dunlap [mailto:wdun...@tibco.com] Sent: Tuesday, March 09, 2010 5:58 PM To: Phil Spector; Tan, Richard Cc: r-help@r-project.org Subject: RE: [R] data frame select max group by like function And yet another way is > isLastIn

Re: [R] data frame select max group by like function

2010-03-09 Thread William Dunlap
To: Tan, Richard > Cc: r-help@r-project.org > Subject: Re: [R] data frame select max group by like function > > Yet another way to do this with base R: > > > dat = read.csv(textConnection('ID, year, score > + tom, 1995, 88 > + rick, 1994, 90 > + mary, 2000

Re: [R] data frame select max group by like function

2010-03-09 Thread Gabor Grothendieck
Try this. The aggregate call gives a data frame with the ID and max score. Then we merge that back with the original data frame so that we pick up the year too: merge(DF, aggregate(DF['score'], DF['ID'], max)) On Tue, Mar 9, 2010 at 1:35 PM, Tan, Richard wrote: > Hi, I have a data frame with 3

Re: [R] data frame select max group by like function

2010-03-09 Thread Phil Spector
Yet another way to do this with base R: dat = read.csv(textConnection('ID, year, score + tom, 1995, 88 + rick, 1994, 90 + mary, 2000, 97 + tom, 1998, 60 + mary, 1998,100')) do.call(rbind,lapply(split(dat,dat$ID),function(x)x[which.max(x$score),])) ID year score mary mary 1998 100 ric

Re: [R] data frame select max group by like function

2010-03-09 Thread Bert Gunter
s. Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Tuesday, March 09, 2010 11:00 AM To: Tan, Richard Cc: r-help@r-project.org Subject: Re: [R] data frame select ma

Re: [R] data frame select max group by like function

2010-03-09 Thread Peter Ehlers
I find ddply() in package plyr handy for this sort of thing: library(plyr) f <- function(x) x[which.max( x[["score"]] ), ] ## x will be a subset of Dat according to ID ddply(Dat, "ID", f) -Peter Ehlers On 2010-03-09 11:59, Ista Zahn wrote: Hi Richard, There are probably better ways, bu

Re: [R] data frame select max group by like function

2010-03-09 Thread Ista Zahn
Hi Richard, There are probably better ways, but here is one approach: Dat <- read.table(textConnection("ID, year, score tom, 1995, 88 rick, 1994, 90 mary, 2000, 97 tom, 1998, 60 mary, 1998,100"), header=TRUE, sep=",") MaxScore <- aggregate(Dat$score, list(Dat$ID), max) names(MaxScore) <- c("ID",

Re: [R] data frame select max group by like function

2010-03-09 Thread Henrique Dallazuanna
Try this: library(sqldf) sqldf("SELECT ID, Year, MAX(score) FROM DF GROUP BY ID") Or do.call(rbind, lapply(split(DF <- DF[order(DF$score),], DF$ID), tail, 1)) On Tue, Mar 9, 2010 at 3:35 PM, Tan, Richard wrote: > Hi, I have a data frame with 3 columns: ID, year and score.  How can I > select f

[R] data frame select max group by like function

2010-03-09 Thread Tan, Richard
Hi, I have a data frame with 3 columns: ID, year and score. How can I select for each unique ID, the year that has the max score? For example, for data frame ID, year, score tom, 1995, 88 rick, 1994, 90 mary, 2000, 97 tom, 1998, 60 mary, 1998,100 I shall have ID, year, score tom, 1995, 88 ric

Re: [R] Data frame column

2010-03-05 Thread David Winsemius
On Mar 5, 2010, at 8:26 AM, ManInMoon wrote: I have a big data frame and I have extracted a bit by doing: y<-d[1:10,6] y [1] Headings 0-49 -98 -49 -41 -120 -155 -204 -169 92329 Levels: -0 -1 -10 -100 -1000 -1 -10001 -10002 -10003 -10004 -10005 -10

Re: [R] Data frame query

2010-03-05 Thread David Winsemius
On Mar 5, 2010, at 7:40 AM, ManInMoon wrote: I have created a large dataframe (d) by getting data from file using read.table I now have 79 columns and 3 million rows. How can I plot the 6th column? I tried plot(d[,6]) but it doesn't look right. When I try to do just d[,6] the console get

[R] Data frame column

2010-03-05 Thread ManInMoon
I have a big data frame and I have extracted a bit by doing: > y<-d[1:10,6] > y [1] Headings 0-49 -98 -49 -41 -120 -155 -204 -169 92329 Levels: -0 -1 -10 -100 -1000 -1 -10001 -10002 -10003 -10004 -10005 -10006 -10007 -10008 -10009 -1001 -10010 -100

[R] Data frame query

2010-03-05 Thread ManInMoon
I have created a large dataframe (d) by getting data from file using read.table I now have 79 columns and 3 million rows. How can I plot the 6th column? I tried plot(d[,6]) but it doesn't look right. When I try to do just d[,6] the console gets some odd "levels" message I don't understand Moon -

Re: [R] data mining

2010-02-25 Thread Tal Galili
It depends on what you want to do. Start by looking at: http://cran.r-project.org/web/views/ There are also some nice startup tutorials on google, start from that... Tal Contact Details:---

[R] data mining

2010-02-25 Thread chinna
how can we achieve data mining using R Project. how to install Rattle gui for R project. can anyone please help me. i want to forecast the results . Thanks in advance. -- View this message in context: http://n4.nabble.com/data-mining-tp1568872p1568872.html Sent from the R help mailing list

Re: [R] data frames; maybe aggregate?

2010-02-12 Thread Phil Spector
Jonathan - split will do what you want: df <- data.frame('id'=c('a','b','a','c','b','a'),'value'=c(6,4,2,9,1,7)) split(df$value,df$id) $a [1] 6 2 7 $b [1] 4 1 $c [1] 9 Thanks for providing a reproducible example! - Phil Spector

[R] data frames; maybe aggregate?

2010-02-12 Thread Jonathan Reichel
Hi all, Another one: Given a data frame with two columns, where the first column (let's call it 'id') has redundant entries, I'd like to get, for each unique value in 'id', a list or vector of all the values from the second column that corresponded to that value. Example: > df <- data.frame(

Re: [R] data frames; matching/merging

2010-02-08 Thread Gabor Grothendieck
Here are 3 solutions assuming DF contains the data frame: > # 1. aggregate > aggregate(DF[2], DF[1], min) V1 V2 1 a 2 2 b 9 3 c 4 > # 2. aggregate.formula - requires R 2.11.x > aggregate(V2 ~ V1, DF, min) V1 V2 1 a 2 2 b 9 3 c 4 > # 3. SQL using sqldf > library(sqldf) > sqldf("se

Re: [R] data frames; matching/merging

2010-02-08 Thread hadley wickham
On Mon, Feb 8, 2010 at 10:39 AM, Jonathan wrote: > Hi all, >    I'm feeling a little guilty to ask this question, since I've > written a solution using a rather clunky for loop that gets the job > done.  But I'm convinced there must be a faster (and probably more > elegant) way to accomplish what

Re: [R] data frames; matching/merging

2010-02-08 Thread S Ellison
You could try aggregate: If we call your data frame df: aggregate(df[2], by=df[1], FUN=min) will get you what you asked for (if not necessarily what you need ;-) ) Switching the columns around is easy enough if you need to; proceeding stepwise: df.new<-aggregate(df[2], by=df[1], FUN=min) df.new

Re: [R] data frames; matching/merging

2010-02-08 Thread David Winsemius
On Feb 8, 2010, at 11:39 AM, Jonathan wrote: Hi all, I'm feeling a little guilty to ask this question, since I've written a solution using a rather clunky for loop that gets the job done. But I'm convinced there must be a faster (and probably more elegant) way to accomplish what I'm looking

Re: [R] data frames; matching/merging

2010-02-08 Thread jim holtman
> x <- read.table(textConnection("V1 V2 + 1a3 + 2a2 + 3b9 + 4c4 + 5a7 + 6b11"), header=TRUE) > closeAllConnections() > # close; matrix with rownames - easy enough to change into a dataframe if you > want > cbind(tapply

Re: [R] data frames; matching/merging

2010-02-08 Thread Ivan Calandra
Hi! I'm definitely not an expert in R (and it's my first reply!), but if I understand right, I think the aggregate function might do what you're looking for. Try ?aggregate to get more info. You might find what you need! HTH Ivan Le 2/8/2010 17:39, Jonathan a écrit : Hi all, I'm feel

Re: [R] data frames; matching/merging

2010-02-08 Thread jim holtman
On Mon, Feb 8, 2010 at 11:39 AM, Jonathan wrote: > Hi all, >    I'm feeling a little guilty to ask this question, since I've > written a solution using a rather clunky for loop that gets the job > done.  But I'm convinced there must be a faster (and probably more > elegant) way to accomplish what

[R] data frames; matching/merging

2010-02-08 Thread Jonathan
Hi all, I'm feeling a little guilty to ask this question, since I've written a solution using a rather clunky for loop that gets the job done. But I'm convinced there must be a faster (and probably more elegant) way to accomplish what I'm looking to do (perhaps using the "merge" function?). I

Re: [R] Data views (Re: (Another) Bates fortune?)

2010-02-08 Thread Douglas Bates
on of (abstract) objects representing data collections as data > frames, with the same properties, but not requesting the creation of an > actual data frame. As far as my (very poor) object-oriented knowledge > goes, these objects should be, in C++/Python parlance, inherit from > data

[R] Data views (Re: (Another) Bates fortune?)

2010-02-07 Thread Emmanuel Charpentier
(very poor) object-oriented knowledge goes, these objects should be, in C++/Python parlance, inherit from data.frame. b) creation of objects implementing various realizations of the objects created in a) : DBMS querying, actual data.frame querying (here I'm thinking of sqldf, which does this on the

Re: [R] Data frame of different sized lists in a function call

2010-01-28 Thread Greg Snow
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Jonathan Greenberg > Sent: Thursday, January 28, 2010 2:03 PM > To: r-help > Subject: [R] Data frame of different sized lists in a function call > > I'm hoping to get some "best pra

Re: [R] Data frame of different sized lists in a function call

2010-01-28 Thread David Winsemius
On Jan 28, 2010, at 4:03 PM, Jonathan Greenberg wrote: list1=c(1:10) # neither of which really are lists list2=c(2:4) lists = list(list1,list2) $ a list of two vectors. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-proj

[R] Data frame of different sized lists in a function call

2010-01-28 Thread Jonathan Greenberg
I'm hoping to get some "best practice" feedback for constructing a function call which takes an undefined set of DIFFERENT length vectors -- e.g. say we have two lists: list1=c(1:10) list2=c(2:4) lists = data.frame(list1,list2) coerces those two to be the same length (recycling list2 to fill

Re: [R] Data Manipulation

2010-01-26 Thread Jim Lemon
On 01/26/2010 09:15 PM, Peter Rote wrote: I still struggling with this: error massage: by(AlexETF,AlexETF$Industry,function(a) {filename = paste("C:/ab/",gsub(" ","",a$Industry[1]),".txt",sep="") + print(filename) + write.table(a[,3,drop=FALSE],quote=FALSE,col.names=FALSE,row.nam

Re: [R] Data Manipulation

2010-01-26 Thread Peter Dalgaard
Peter Rote wrote: > I still struggling with this: > > error massage: > >> by(AlexETF,AlexETF$Industry,function(a) {filename = paste("C:/ab/",gsub(" >> ","",a$Industry[1]),".txt",sep="") > + print(filename) > + write.table(a[,3,drop=FALSE],quote=FALSE,col.names=FALSE,row.names=FALSE)

<    5   6   7   8   9   10   11   12   13   14   >