Reputation: 2544
I am following an example here: ggplot2 - Multiple Boxplots from Sources of Different Lengths and trying to adapt it to my data. You can access my data here: https://drive.google.com/drive/folders/1A4P6vaHgqrmeakCGR-zMYZQvyDgZLrzw?usp=sharing
My code:
JD <- data.frame(group="JD",value=scan("......../abs_len_jd.csv", what="", sep="\n"))
LI <- data.frame(group="LI",value=scan("........./abs_len_li.csv", what="", sep="\n"))
JAS <- data.frame(group="JAS",value=scan("....../abs_len_jas.csv", what="", sep="\n"))
# Combine into one long data frame
plot.data <- rbind(JD, LI, JAS)
# Plot
ggplot(plot.data, aes(x=group, y=value, fill=group)) + geom_boxplot()
The resulting plot does not look like box plot at all:
What have I done wrong? Thanks
Upvotes: 2
Views: 773
Reputation: 39595
Try with this. You would need a group
var. If I am correct, it should be your group according to the file and then having one box per class:
library(ggplot2)
# Combine into one long data frame
plot.data <- rbind(JD, LI, JAS)
plot.data$value <- as.numeric(plot.data$value)
# Plot
ggplot(plot.data, aes(x=group, y=value, fill=group,group=group)) + geom_boxplot()
Output:
Upvotes: 1