Re: [R] selecting rows by maximum value of one variables in dataframe nested by another Variable

2012-06-27 Thread Petr PIKAL
Hi How could I select the rows of a dataset that have the maximum value in one variable and to do this nested in another variable. It is a dataframe in long format with repeated measures per subject. I was not successful using aggregate, because one of the columns has You could do it

Re: [R] selecting rows by maximum value of one variables in dataframe nested by another Variable

2012-06-27 Thread Rui Barradas
Hello, Here's a solution using aggregate and merge. I've kept it in two steps for clarity. d - read.table(text= subjecttime.ms V3 1 1 stringA 1 12 stringB 1 22 stringC 2 1stringB 2 14 stringC 2 25 stringA , header=TRUE) ag -

Re: [R] selecting rows by maximum value of one variables in dataframe nested by another Variable

2012-06-27 Thread arun
HI, Try this: dat1 - read.table(text= subject    time.ms V3 1  1  stringA 1  12  stringB 1  22    stringC 2  1    stringB 2  14  stringC 2  25  stringA , sep=,header=TRUE) dat2-aggregate(dat1$time.ms,list(dat1$subject),max) colnames(dat2)-c(subject,time.ms)  

[R] selecting rows by maximum value of one variables in dataframe nested by another Variable

2012-06-26 Thread Miriam
How could I select the rows of a dataset that have the maximum value in one variable and to do this nested in another variable. It is a dataframe in long format with repeated measures per subject. I was not successful using aggregate, because one of the columns has character values (and/or