Hi,
I am trying to simply make a summary table using dplyr with means and standard deviations of a few variables. Most of my standard deviations return NA (but oddly two calculations return numbers). I have subseted my data so that I don't have any NA in the dataframe. My variables are all numeric. The means turn out fine. What else do I need to check to get these standard deviations to work?!
hab=my data
a<-hab %>% group_by(year, eco, id) %>% summarize(sst=mean(SST, na.rm=TRUE),sstSD=sd(sst, na.rm=TRUE),
depth=mean(depth, na.rm=TRUE),depthSD=sd(depth, na.rm=TRUE),
slope=mean(slope),slopeSD=sd(slope, na.rm=TRUE),
ssh=mean(ssh, na.rm=TRUE),
eke=mean(eke, na.rm=TRUE),
hill=mean(hill, na.rm=TRUE),
d2ed=mean(disttocenter, na.rm=TRUE),
wind=mean(windsp, na.rm=TRUE))
I am also trying to take the means from a and do the same thing. This time all of the standard deviations equal NA.
b<-a %>% group_by(eco,year) %>% summarize(sst=mean(sst, na.rm=TRUE),sstSD=sd(sst, na.rm=TRUE),
depth=mean(depth, na.rm=TRUE),depthSD=sd(depth, na.rm=TRUE),
slope=mean(slope),slopeSD=sd(slope, na.rm=TRUE),
ssh=mean(ssh, na.rm=TRUE),sshSD=sd(ssh, na.rm=TRUE),
eke=mean(eke, na.rm=TRUE),ekeSD=sd(eke, na.rm=TRUE),
hill=mean(hill, na.rm=TRUE),hillSD=sd(hill, na.rm=TRUE),
d2ed=mean(d2ed, na.rm=TRUE),d2edSD=sd(d2ed, na.rm=TRUE),
wind=mean(wind, na.rm=TRUE),windSD=sd(wind, na.rm=TRUE))
Thanks!