Re: [R] Sorting data from one column with strings

2010-11-04 Thread jim holtman
try sqldf: > x Sample_no Species Nitrogen Carbon 1 1 Cod 15.2 -19.0 2 2 Haddock 14.8 -20.2 3 3 Cod 15.6 -18.5 4 4 Cod 13.2 -20.1 5 5 Haddock 14.3 -18.8 > require(sqldf) > sqldf("select Species, avg(Nitrogen) Nitrogen, a

Re: [R] Sorting data from one column with strings

2010-11-04 Thread Mike Rennie
(apologies for any double hits; forgot to reply all...) Or, you could just go back to basics, and write yourself a general loop that goes through whatever levels of a variable and gives you back whatever statistics you want... below is an example where you estimate means for each level, but you co

Re: [R] Sorting data from one column with strings

2010-11-04 Thread Eigenhuis, Annemarie
Try tapply(). For example: tapply(data$Nitrogen,factor(data$Species),mean) For the Nitrogen column, the mean is calculated for each Species. (if the data frame below is in the object data) Regards, Annemarie Eigenhuis -Original Message- From: r-help-boun...@r-project.org [mailto:r-he

Re: [R] Sorting data from one column with strings

2010-11-04 Thread David Winsemius
On Nov 4, 2010, at 8:28 AM, Ramsvatn Silje wrote: Hello, I have tried to find this out some other way, but unsuccessful I have to try this list. I assume this should be quite simple. I have a dataset with 4 columns, "Sample_no", "Species", "Nitrogen", "Carbon" in csv format. In the specie