[R] Descriptive Stats from Data Frame
Rich Shepard
rshepard at appl-ecosys.com
Tue Aug 30 23:28:53 CEST 2011
On Wed, 31 Aug 2011, Tal Galili wrote:
> It is a bit hard to read the "summary" you are using. Consider please
> pasting the output of:
> ls.str(chemdata)
Tal,
Yes, summary() is inappropriate. I do want str() instead. And what that
shows is:
> str(chemdata)
'data.frame': 14886 obs. of 1 variable:
$ site_id.sample_date.param.quant: Factor w/ 14886 levels
"BC-0.5|1996-04-19|Arsenic|0.01",..: 11579 14219 13298 11982 11909 13371
13082 111 12 23 ...
> Regarding your question, please start and see if this work (I'm not sure,
> since it seems you have made some changes to the summary output, and I am
> only guessing how things look):
> mean(chemdata$quant[chemdata$param > =="Arsenic"])
> mean(chemdata$quant[chemdata$param > =="Arsenic"])
Error: unexpected '==' in "mean(chemdata$quant[chemdata$param > =="
> mean(chemdata$quant[chemdata$param =="Arsenic"])
[1] NA
Warning message:
In mean.default(chemdata$quant[chemdata$param == "Arsenic"]) :
argument is not numeric or logical: returning NA
I find it easy following the syntax in the half-dozen or more books I've
read, but quite difficult to apply what I read to my own real-world data.
:-)
Thanks,
Rich
More information about the R-help
mailing list