title: “Assignment 1 - SD with R” author: “Alekhya Kondragunta” date: “2024-09-03” output: html_document
#1. Find the SD for your measurements using R.
x <- c(1.2, 3.0, -4, 5, 6, -2, 4, 6, 6, 2.3, 5, 6, 4, 3)
sd(c(1.2, 3.0, -4, 5, 6, -2, 4, 6, 6, 2.3, 5, 6, 4, 3), na.rm=TRUE)
## [1] 3.074148
#2. Use the following functions. Create variables to help your calculations.
#i. sum, mean, length, ^2 (to square a value), sqrt
sum(c(x))
## [1] 45.5
mean(c(x))
## [1] 3.25
length(c(x))
## [1] 14
x^2
## [1] 1.44 9.00 16.00 25.00 36.00 4.00 16.00 36.00 36.00 5.29 25.00 36.00
## [13] 16.00 9.00
x_sqrt <- sqrt(x) #We are applying the sqrt to the vector x
## Warning in sqrt(x): NaNs produced
x_sqrt
## [1] 1.095445 1.732051 NaN 2.236068 2.449490 NaN 2.000000 2.449490
## [9] 2.449490 1.516575 2.236068 2.449490 2.000000 1.732051
#3. Investigate your data. Plot histogram of data with function hist
hist(x)
#4. How different are the plots for 3 vs. 10?
hist(x, breaks=10)
hist(x, breaks=3)