Install MASS package in RStudio. Download crabs data set available in the MASS library. The data set
Question:
Install MASS package in RStudio. Download crabs data set available in the MASS library. The data set contains five morphological variables measured on 200 crabs of the Leptograpsus
variegatus species that have been collected in Fremantle, Australia. Explore the data set using different operations or functions to learn more about the variables, rows, and columns. sp corresponds to variety (B=blue; O=orange); FL to the size of the frontal lobe (in mm), RW to the width of the abdomen (in mm), CL to the length of the shell (in mm), CW to the width of the shell (in mm), and BD to the body depth (in mm). Create five different graphs from the data. Compare the shell length between orange and blue female crabs using the codes below:
> crabs2<-subset(crabs,sex=="F",select=c("sp","CL"))
> B<-mean(subset(crabs2,sp=="B")$CL)
> O<-mean(subset(crabs2,sp=="O")$CL)
> ggplot(crabs2, aes(x=CL,y=..density.., fill=sp,color=sp)) +
+ geom_histogram(position="identity",alpha=0.1)+xlab(label="Shell
+ lengths (mm)")+ylab(label="Relative amounts")+
+ scale_color_manual(values=c("Blue",
+ "Orange"))+geom_density(alpha=0.3)+
+ scale_fill_manual(values=c("Blue", "Orange"))+
+ theme(legend.position="right",panel.background=element_rect(fill=
+ "white", colour="grey50"))+
+ geom_vline(aes(xintercept=B),color="blue", size=2)+
+ geom_vline(aes(xintercept=O),color="orange", size=2)
Estimate the means for the two samples. Observe the histograms, density curves, and means to determine whether the two samples follow normal distribution. Study and modify the codes above to compare the shell length between orange and blue male crabs. Estimate the means for the two samples. Observe the histograms, density curves, and means to determine whether the two samples follow normal distribution.