I'm learning R for the first time and I am working with boxplots. I want to have some of the box plots filled if they meet a condition. I am using 'diamonds' a general dataset from base R to generate these box plots.
I'm having difficulties accessing the 'caret' element of the dataset 'diamonds' in the following code.
diamonds %>%
ggplot(mapping = aes(x = color, y = price)) +
geom_boxplot(mapping = aes(fill = caret > median(caret))) +
facet_grid(clarity ~ cut) +
theme(legend.position = "top")
The error message I am receiving is the following:
Error in FUN(X[[i]], ...) : object 'caret' not found
If anyone knows more about R and can show me why caret is not found, I would really appriciate it! Thank you!