SD from Mean | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

SD from Mean

Oftentimes, the standard deviation is used to understand the dispersion of the data. We are working with the mtcars dataset and need to find the number of cars that fall into 1 standard deviation from the mean of the mpg column. This means that we need to find the cars that have the mpg value in the range of mean(mpg)-sd(mpg) and mean(mpg)+sd(mpg).

4th Apr 2023, 6:45 AM
Grace Johnruz Imperial
2 Answers
+ 3
What is your question? Please tag the relevant programming language, show your code attempt and give a complete task description.
4th Apr 2023, 6:47 AM
Lisa
Lisa - avatar
0
mean1 <- mean(mtcars$mpg) sd1 <- sd(mtcars$mpg) lowr <- mean1 - sd1 uppr <- mean1 + sd1 in_range <- subset(mtcars, mpg >= lowr & mpg <= uppr, select= c(mpg)) print(length(in_range$mpg))
4th Apr 2023, 6:45 AM
Grace Johnruz Imperial