set.seed(123) # Sets a seed for reproducibility
vec4 <- sample(1:100, 100, replace = TRUE)
min(vec4)
## [1] 4
max(vec4)
## [1] 99
mean(vec4)
## [1] 52.15
median(vec4)
## [1] 50
quantile (vec4)
## 0% 25% 50% 75% 100%
## 4.00 26.75 50.00 79.50 99.00
sd(vec4)
## [1] 29.57592
var(vec4)
## [1] 874.7348
IQR(vec4)
## [1] 52.75
diff(range(vec4))
## [1] 95
weight = c(60,72,57,90,95,72)
height = c(1.75,1.8,1.65,1.9,1.74,1.91)
This said there is an error but works fine ¯|(ツ)|¯
gender = c("m", "f","m","f","f","m")
gender
## [1] "m" "f" "m" "f" "f" "m"
class(gender)
## [1] "character"
"character"
## [1] "character"
plot(height,weight,col = "red", pch=9)
plot(factor(gender),weight)
ghw = data.frame(gender,height,weight)
View(ghw)
This calculates both BMI and CI
ghw$bmi = ghw$weight/ghw$height^2
ghw
## gender height weight bmi
## 1 m 1.75 60 19.59184
## 2 f 1.80 72 22.22222
## 3 m 1.65 57 20.93664
## 4 f 1.90 90 24.93075
## 5 f 1.74 95 31.37799
## 6 m 1.91 72 19.73630
g1 = c(34, 49, 64, 38, 60, 78, 67, 36, 19, 37)
g2 = c(77, 75, 78, 41, 51, 20, 61, 73, 76, 38)
quantile(g2)
## 0% 25% 50% 75% 100%
## 20.00 43.50 67.00 75.75 78.00
boxplot (g2)