Re: [R] subsetting question

2015-05-20 Thread MacQueen, Don
Assuming datums is a vector of the unique dates in Date... perhaps datums <- sort(unique(dataset1$Date)) I usually set it up like this for (i in 1:length(datums) ) { crnt.date <- datums[i] tmpdat <- subset(dataset1, Date==crnt.date) cat(i, format(crnt.date), 'dim(tmpdat)',dim(tmpdat),'\n

Re: [R] subsetting question

2015-05-20 Thread William Dunlap
Here is a self-contained example of what you might be trying to do. You would get better answers if you supplied this yourself. dataset1 <- data.frame(Date=as.POSIXct(c("2015-04-01","2015-04-01","2015-04-07", "2015-04-19")), Weight=11:14) datums <- as.POSIXct(c("2015-04-01", "2015-04-08", "2015-04

Re: [R] subsetting question

2015-05-20 Thread Ivan Calandra
Hi, What about using functions like aggregate()? Something like: aggregate(Weight~datums, data=dataset1, FUN=mean) If you need to do more things, you can create your own function for 'FUN' HTH, Ivan -- Ivan Calandra, ATER University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplana

[R] subsetting question

2015-05-20 Thread Dieter Anseeuw
Dear all, I would like to do multiple actions on a subset of my data. Therefore, I want to create a for loop on the variable "Date" (actually a double for loop on yet another variable, but let's omit that for a moment). I want to run down every level of "Date" and perform multiple actions on the

Re: [R] Subsetting question

2011-10-05 Thread jim holtman
Does this do what you want: > data1 A B 1 1 a 2 1 b 3 2 c 4 2 d > data2 D E F 1 x y 1 2 w z 2 > data1.1 <- aggregate(data1$B, list(data1$A), FUN=paste, collapse=',') > data1.1 Group.1 x 1 1 a,b 2 2 c,d > merge(data2, data1.1, by.x="F", by.y="Group.1") F D E x 1 1 x y a,b 2

[R] Subsetting question

2011-10-05 Thread darkgaze
Hi all, Suppose I have data1 A B 1 a 1 b 2 c 2 d and data2 D E F x y 1 w z 2 and I want data2 D E F G x y 1 a,b w z 3 c,d I am trying data2$G=list(data1$B[data1$A==data2$F,]) How do I correct this approach? -- View this message in context: http://r.789695.n4.nabble.com/Subsetting-questi