[R] Remove specific rows in a matrix/data.frame

Eik Vettorazzi E.Vettorazzi at uke.de
Thu Oct 13 21:26:46 CEST 2011


Hi,
just put it in the formula:

aggregate(Number ~ Letter+Test,data=dtf,max)

cheers

Am 13.10.2011 19:30, schrieb syrvn:
> Hello again,
> 
> 	
> dtf<-read.table(textConnection("Letter Test Number 
> 							a b 1 
> 							a b 1 
> 							b b 1 
> 							b b 0 
> 							c b 0 
> 							c b 1 
> 							d b 0 
> 							d b 0"),header=T) 
> aggregate(Number ~ Letter,data=dtf,max)
> 
> how can I adjust this solution that the results also includes "Test"?
> 
> I tried:
> 
> aggregate(Number ~ Letter,data=dtf,max,by=list("Letter", "Test", "Number"))
> 
> But it breaks with the following error message:
> 
> Error in aggregate.data.frame(mf[1L], mf[-1L], FUN = FUN, ...) : 
>   arguments must have same length
> 
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Remove-specific-rows-in-a-matrix-data-frame-tp3902149p3902286.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790



More information about the R-help mailing list