FAQ
How do you calculate the percentage of data within 2SD, 3SD, 4SD, 5SD, and
6SD of the mean? I used the following link as the data I'm working with:
this helps answer my question. Can you please explain how to calculate the
SD's? Please be specific in which part of the function changes when
calculating the next SD up.

Thanks.

--
View this message in context: http://r.789695.n4.nabble.com/How-to-Calculate-Percentage-of-Data-within-certain-SD-of-Mean-tp4359551p4359551.html
Sent from the R help mailing list archive at Nabble.com.

Search Discussions

•  at Feb 5, 2012 at 9:13 pm ⇧

# Calculate Stats
total = length(nb10[,1])
mean = mean(nb10[,1])
sd = sd(nb10[,1])

# Function ... nSD is the number of SD you are looking at
pData <- function(nSD){
lo = mean - nSD/2*sd
hi = mean + nSD/2*sd
percent = sum(nb10[,1]>=lo & nb10[,1]<=hi)/total *100
}

# Output ...
print(paste("Percent of data within 2 SD is ",pData(2),"%", sep="")) # 86%
print(paste("Percent of data within 3 SD is ",pData(3),"%", sep="")) # 93%
print(paste("Percent of data within 4 SD is ",pData(4),"%", sep="")) # 96%
print(paste("Percent of data within 5 SD is ",pData(5),"%", sep="")) # 97%
print(paste("Percent of data within 6 SD is ",pData(6),"%", sep="")) # 98%

HTH

Pete

Ajata Paul wrote
How do you calculate the percentage of data within 2SD, 3SD, 4SD, 5SD, and
6SD of the mean? I used the following link as the data I'm working with:
this helps answer my question. Can you please explain how to calculate
the SD's? Please be specific in which part of the function changes when
calculating the next SD up.

Thanks.

--
View this message in context: http://r.789695.n4.nabble.com/How-to-Calculate-Percentage-of-Data-within-certain-SD-of-Mean-tp4359551p4359809.html
Sent from the R help mailing list archive at Nabble.com.

Related Discussions

Discussion Overview
 group r-help categories r posted Feb 5, '12 at 7:05p active Feb 5, '12 at 9:13p posts 2 users 2 website r-project.org irc #r

2 users in discussion

Content

People

Support

Translate

site design / logo © 2018 Grokbase