> table(airquality$Month)
5 6 7 8 9
31 30 31 31 30
> airquality2<-airquality%>%group_by(Month)%>%summarise(mean_temp=mean(Temp))
> View(airquality2)
> airquality3<-airquality%>%filter(Month!=7)
> table(airquality3$Month)
5 6 8 9
31 30 31 30
> airquality3<-airquality3%>%group_by(Month)%>%summarise(mean_temp=mean(Temp))
> View(airquality3)
<The way to make x of the line graph from continuous to discrete - not containing the value x=7>
> ggplot(data=airquality3,aes(x=factor(Month),y=mean_temp))+geom_line()
geom_path: Each group consists of only one observation.
Do you need to adjust the group aesthetic?
when the variable x is the factor type, you must set aes(group=1) to make the graph consists of a line.
> ggplot(data=airquality3,aes(x=Month,y=mean_temp))+geom_line() |
> ggplot(data=airquality3,aes(x=factor(Month),y=mean_temp,group=1)) +geom_line() |
containing Month=7 in the graph |
not containing Month=7 in the graph |
<expand the limit of the graph (y=0 to y=max)>
>ggplot(data=airquality3,aes(x=factor(Month),y=mean_temp,group=1)) +geom_line() |
> ggplot(data=airquality3,aes(x=factor(Month),y=mean_temp,group=1)) +geom_line() +ylim(0,max(airquality3$mean_temp)) |
> ggplot(data=airquality3,aes(x=factor(Month),y=mean_temp,group=1)) +geom_line() +expand_limits(y=0) |
|
|
|