YouTip LogoYouTip

R Func Sd

# Calculate mean and standard deviation print(paste("Group 1 - Mean:", mean(group1), "Standard Deviation:", sd(group1))) print(paste("Group 2 - Mean:", mean(group2), "Standard Deviation:", sd(group2)))

Executing the above code produces:

 "Group 1 - Mean: 85 Standard Deviation: 0.925820099772551" "Group 2 - Mean: 85 Standard Deviation: 15.1186472433265"

Standard deviation is commonly used for probability estimation in normal distributions. Approximately 68% of data falls within the range of mean Β±1 standard deviation:

Example

# Generate normal distribution data

set.seed(123)

scores <-rnorm(1000, mean=70, sd=10)

# Calculate mean and standard deviation

m <-mean(scores)

s <-sd(scores)

# Calculate the proportion within Β±1 standard deviation

within_1sd <-mean(scores >= m - s & scores <= m + s)

print(paste("Mean:", round(m, 2)))

print(paste("Standard Deviation:", round(s, 2)))

print(paste("Proportion within Β±1 Standard Deviation:", round(within_1sd *100, 1), "%"))

Executing the above code produces:

 "Mean: 69.97" "Standard Deviation: 10.03" "Proportion within Β±1 Standard Deviation: 68.1 %"

Image 4: R Language Examples R Language Examples

← R Func SeqR Func Scale β†’