Write the R code to get the graphs in the image below Use the following data set
ID: 3042637 • Letter: W
Question
Write the R code to get the graphs in the image below
Use the following data set.
I know the beginning of the code is:
> MentalHealth$MonthNumber<-c(8:12,1:12,1:12,1:7)
> MonthNumber<-factor(MentalHealth$MonthNumber)
Please write the rest of the code to get the graphs
Thank you
Month
Moon
Admission
Aug
Before
6.4
Sep
Before
7.1
Oct
Before
6.5
Nov
Before
8.6
Dec
Before
8.1
Jan
Before
10.4
Feb
Before
11.5
Mar
Before
13.8
Apr
Before
15.4
May
Before
15.7
Jun
Before
11.7
Jul
Before
15.8
Aug
During
5
Sep
During
13
Oct
During
14
Nov
During
12
Dec
During
6
Jan
During
9
Feb
During
13
Mar
During
16
Apr
During
25
May
During
14
Jun
During
14
Jul
During
20
Aug
After
5.8
Sep
After
9.2
Oct
After
7.9
Nov
After
7.7
Dec
After
11
Jan
After
12.9
Feb
After
13.5
Mar
After
13.1
Apr
After
15.8
May
After
13.3
Jun
After
12.8
Jul
After
14.5
Month
Moon
Admission
Aug
Before
6.4
Sep
Before
7.1
Oct
Before
6.5
Nov
Before
8.6
Dec
Before
8.1
Jan
Before
10.4
Feb
Before
11.5
Mar
Before
13.8
Apr
Before
15.4
May
Before
15.7
Jun
Before
11.7
Jul
Before
15.8
Aug
During
5
Sep
During
13
Oct
During
14
Nov
During
12
Dec
During
6
Jan
During
9
Feb
During
13
Mar
During
16
Apr
During
25
May
During
14
Jun
During
14
Jul
During
20
Aug
After
5.8
Sep
After
9.2
Oct
After
7.9
Nov
After
7.7
Dec
After
11
Jan
After
12.9
Feb
After
13.5
Mar
After
13.1
Apr
After
15.8
May
After
13.3
Jun
After
12.8
Jul
After
14.5
Moon Before During 5 1 2 3 4 5 678 9 10 12 MonthNumber MonthNum 1 After Before During.. -1 Moon 12Explanation / Answer
>MoonBefore<-MentalHealth[MentalHealth$Moon=="Before",c("Month","Admission")]
> MoonDuring<-MentalHealth[MentalHealth$Moon=="During",c("Month","Admission")]
> MoonAfter<-MentalHealth[MentalHealth$Moon=="After",c("Month","Admission")]
>a<-c(1:12)
> MoonAfter$number<-a
> plot(MoonAfter$number,MoonDuring$Admission,col="red",lwd=3)
> lines(MoonAfter$number,MoonAfter$Admission,col="red",lwd=3)
> lines(MoonAfter$number,MoonAfter$Admission,col="blue",lwd=3)
> lines(MoonAfter$number,MoonBefore$Admission,col="green",lwd=3)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.