Reputation: 11
I'm new to R and I'm trying to understand how to do the mean +- 2 times standard deviation. I've tried calculating the mean and the standard deviation singularly and then do the aritmetic calculation but everything I try to do gives me error.
mean <- aggregate(data$distance, list(data$dose), FUN=mean, na.rm=TRUE)
sd <- aggregate(data$distance, list(data$dose), FUN=sd, na.rm=TRUE)
mean_sd <- ("mean", "%+-%", "2*(sd)")
where data is my initial data, distance is the value from which I want to do the mean and standard deviation and the different doses are the groups.
It gives me:
mean_sd <- ("mean", "%+-%", "2*(sd)")
# Error: unexpected ',' in "mean_sd <- ("mean","
After this, I also wanted to select the IDs from the data that have the mean higher or smaller than the value I'll find (mean +- 2 sd). For instance, I have several IDs, for each of them I have several doses and the value of the distance.
Upvotes: 1
Views: 141