I'm trying to make a two box plots side by side on the SAME graph in R, to show case the following:
Treatment Distance
1 Control 50.0
2 Control 60.5
3 Control 63.5
4 Control 77.5
5 Control 51.5
6 Control 39.0
7 Control 80.0
8 Control 57.0
9 Control 55.0
10 Control 41.0
11 Control 18.0
12 Control 95.0
13 Control 52.0
14 Control 63.5
15 Control 58.0
16 Control 128.0
17 Control 106.5
18 Control 83.1
19 Control 83.5
20 Control 119.5
21 Control 31.0
22 Control 48.5
23 Control 44.0
24 Control 54.0
25 Control 43.5
26 Control 53.0
27 Recovery 117.5
28 Recovery 34.0
29 Recovery 49.0
30 Recovery 62.0
31 Recovery 71.5
32 Recovery 7.0
33 Recovery 71.5
34 Recovery 25.5
35 Recovery 61.5
36 Recovery 131.0
37 Recovery 78.0
38 Recovery 14.0
39 Recovery 31.0
40 Recovery 44.0
41 Recovery 26.5
42 Recovery 31.5
43 Recovery 40.5
I've tried to use the following command to graph them, but it won't work, please let me know the exact command in R to graph this. My command: boxplot(fishJump$Treatment~fishJump$Distance). I get the following error:
Error in oldClass(stats) <- cl :
adding class "factor" to an invalid object
Also what is the command to label these two different box-plots on the SAME graph.
One more thing, I need to make a normal QQ plot for the same data, treatment/control and treatment/recovery, but seperate graphs, what command would I use for this?
Thanks in advance.
R-commands for plotting boxplot
first import the data file into R and should be in CSV format, Use the command
d=read.csv(file.choose()) #select data file
attach(d)
boxplot(as.numeric(Treatment)) # it will plot boxplot for Treatment
boxplot(Distance) # It will plot boxplot for Distance
boxplot(d) # this command will plot both the boxplot of Treatment & Distance on same graph
# use below command for Q-Q plot
> qqnorm(as.numeric(Treatment))
> qqline(as.numeric(Treatment),col="#000000")
Get Answers For Free
Most questions answered within 1 hours.