x<--c(rnorm(100, mean =0.5, sd =2), # Create synthetic datarnorm(100, mean =-3, sd =4),rnorm(100, mean =2, sd =0.5))y<--c(rnorm(200, mean =1, sd =3),rnorm(100, mean =-1, sd =0.7))+0.7*x
Create dataframe called my_data and create 3 groups and 4 subgroups
my_data<-data.frame(x =x, y =y, group =rep(LETTERS[1:3], each =100), subgroup =sample(letters[1:4], size =300, replace =TRUE))view(my_data)
Create scatterplot with each group a different colour
ggplot(data =my_data, # Scatterplot without facetsaes(x =x, y =y, color =group))+geom_point()
Create multiplot with each group as a facet and displayed in a different subplot,
In this module, we will continue working with the airquality data set and introduce a new variable for grouping days into specific ranges. To prepare, we will install and load the dplyr and ggplot2 packages, convert the Month column to a factor class, and create a new factor variable DayRange that categorizes the Day column into ranges: <=10, 11-20, and >20.