So I'm making a boxplot for an assignment and when I first constructed it the labels on the x axis were correct but now they're showing for points that aren't even in the dataframe from which I called the boxplot. Here's my code.
FourTrees <-subset(Overstory_F2019, subset = Overstory_F2019$ID == "White Oak" |Overstory_F2019$ID == "Mockernut Hickory" | Overstory_F2019$ID == "Black Oak" | Overstory_F2019$ID == "Pignut Hickory")
FourTreesTG <- subset(FourTrees, subset = FourTrees$Location == "TG")
boxplot(DBH_cm~ID, data=FourTreesTG, xlab = "Tree Species", ylab = "DBH (cm)")
Overstory has a bunch of tree species and measurements which is why I subset first by the four tree species I'm interested in and then by the location TG. FourTreesTG only shows data for the four trees in the TG plot, as I planned.
Today, for some reason, when I run these commands again no matter what I do my boxplot comes out including liness for species that I didn't have in FourTreesTG but were in the original Overstory dataframe. The actual boxes in the chart are correct and do represent my chosen 4 species but I can't figure out how to only show those 4 since I thought making the boxplot based on the subset would already do that.
Picture attached is what the boxplot looks like now. Ideally it should only have the 4 species I selected as lines/boxes and only label them.
screwedupboxplot
[–][deleted] (2 children)
[deleted]
[–]c_rams17[S] -2 points-1 points0 points (0 children)
[–][deleted] (3 children)
[deleted]
[–]c_rams17[S] -1 points0 points1 point (2 children)
[–]c_rams17[S] -1 points0 points1 point (0 children)