In: Statistics and Probability
Please use RStudio to answer the question and give the R command:
please load data use data:
library(MASS)
data(cats)
Use the “cats” data set to test for the variance of the body weight in male and female cats
Solution:
library(MASS)
data(cats)
dim(cats)
print(cats)
library(dplyr)
var_group= cats %>% group_by(Sex) %>%
summarise_at(vars(Bwt), funs(n(), var(., na.rm = TRUE)))
print(var_group)
Output
Sex n var
<fct> <int> <dbl>
1 F 47 0.0751
2 M 97 0.219
>