I am trying to create three boxplot graphs, each with 5 categories showing the count of three species in one hour intervals 1-5. i.e. boxplot1 showing species1 count in hours 1-5, boxplot2 showing species2 count in 1-5, and boxplot3 showing species3 count in 1-5 all in the same window.
The data is read from a .csv with five columns: Date, Hour, species1, species2, species3. 'Hour' values are numerical values 1-5 and numeric counts for each species are in corresponding columns. 'Date' denotes the date of the observation. When I plot the three boxplots side-by-side using par(mfrow) I am only given Hour categories 1 and 2 in the x-margin. I would like to have 5 categories for each species representing hours 1-5.
Here is my code:
spec1_plot=boxplot(data$spec1,data$Hour)
par(mfrow=c(1,3))
spec2_plot=boxplot(data$spec2,data$Hour)
spec3_plot=boxplot(data$spec3,data$Hour)
Here is the plot I am given: species count by hour
How can I get it to also show hours 3-5 for each species?
Convert the "Hour" column to factors with desired levels, see this example:
x <- mtcars
boxplot(mpg ~ cyl, data = x)
#convert to factor with levels
x$cyl <- factor(x$cyl, levels = 4:10)
boxplot(mpg ~ cyl, data = x)