In: Computer Science
Use the Galton dataset from the mosaicData package in R STUDIO
library(mosaic)
Create a scatter plot to show the relationship between height against father’s height (x=father, y=height)
What relationship did you see? (Use comments to write in your R Markdown file)
Separate your plot into facets by sex
Add a regression line using the “lm” method to both of your facets
Generate a box plot of height by sex.
Use the RailTrail data from the mosaicData package
library(mosaic)
Generate a scatter plot to show the relationship between the number of crossings per day volume against the high temperature that day
Separate your plot to facets by weekday
library(mosaic)
library(ggplot2)
head(Galton)
###part a
p <- ggplot(Galton, aes(x=father, y=height)) +
geom_point(shape=1)
p
###part b
### from scatter plot, we can see fathers height and height have
+ve corelation and are nearly
### in linear relation
###part c
p + facet_grid(sex ~ .)
####part d
p+facet_grid(sex ~ .) +geom_smooth(method="lm")
######part e
ggplot(Galton, aes(x=sex, y=height)) +
geom_boxplot(notch=TRUE)
library(mosaic)
library(ggplot2)
head( RailTrail )
###part a
p <- ggplot(RailTrail , aes(x=hightemp , y=volume )) +
geom_point(shape=1)
p
###part b
p + facet_grid(weekday~ .)