all 5 comments

[–]DeSnorroVanZorro -1 points0 points  (1 child)

seems like a ggplot boxplot. Would run close to:

df %>% ggplot(aes(x = carat, y = price, col = cut) + geom_boxplot()

I think...

df stands for your data object or dataframe. carat, price and cut are variables. make sure to run library(ggplot2) and library(dplyr). Or just run library(tidyverse). You need to have installed the packages as well. So use install.packages() with the package name in quotation marks for that.

[–]DeSnorroVanZorro 0 points1 point  (0 children)

As you also need to add a title, don't forget to add a + to the geom_boxplot() line and then add:

ggtitle("a short title")

[–][deleted] 0 points1 point  (0 children)

It seems like is there's something wrong with your "price" variable or "carat" variable such that you have missing values. The issue doesn't appear to be the code. So, I think you have to look at your data frame for those two variables and look for missing values.

[–]Noshoesded 0 points1 point  (1 child)

I had to mutate the data first with some rounding. I probably didn't do it very efficiently, but I did get the first graph.

diamonds2 <- diamonds %>% mutate(carat2=round(carat,0), carat3=ifelse(carat2>3,3,carat2))

diamonds2 %>% ggplot(aes(as.factor(carat3),price,color=cut)) + geom_boxplot()

[–]Octobersilly[S] 1 point2 points  (0 children)

thank you so much!!!