New to R and appreciate advice! I am trying to plot multiple boxplots on the same graph, split by date. My data is saved in a .csv, and the code I am trying right now is the following. I suspect my as.Date function is not working appropriately. Any help is much appreciated! Data is in csv columns of "Day" and "Strength". Date formatting in the .csv is, for example, "5/1/21" for May 1, 2021.
FG <- read.csv("/Users/L/Downloads/ResultsFG.csv", header=T, na.strings=c("")) library(ggplot2) FG$Day <- as.Date(FG$Day) FG$Day <- format(FG$Day, "%b-%d") FG$Day <- factor(FG$Day, levels=c("May-1","May-2","May-3", "May-4", "May-5", "May-6", "May-7", "May-87", "May-9", "May-10", "May-11", "May-14", "Mar-17", "May-18", "May-19", "May-20", "May-21", "May-22", "May-24", "May-25", "May-26", "May-27", "May-28", "May-29", "May-30", "May-31")) ggplot() + geom_boxplot(data = FG, aes(x = factor(Day, level = d_order), y = Strength), color = "forestgreen", fill= "forestgreen", alpha = 0.1) I don't get any error messages, but I do get one large boxplot labeled on the X axis as "NA". (screenshot below) Can you help me split this by date?
single boxplot generated, X axis = "NA"
ETA: Strange result after I call the Day column after trying to convert it
> FG$Day [1] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [9] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [17] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [25] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [33] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [41] <NA> <NA> <NA> <NA> May-21 May-21 May-21 May-21 [49] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [57] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [65] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [73] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [81] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [89] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> [97] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> 26 Levels: May-1 May-2 May-3 May-4 May-5 May-6 May-7 ... May-31 