我正在尝试使用ISLR软件包中的Wage数据库用ggplot2绘制箱形图。箱形图用于可视化工资与教育程度的关系,分为五个类别。当我尝试使用典型代码生成箱形图时,从Rstudio得到以下警告:
Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.
Error: Aesthetics must be either length 1 or the same as the data (3000): y
我的代码是
library("ISLR")
library("MASS")
setwd("C:/Users/Alonso/Desktop/ITSL")
View(Wage)
ggplot(Wage, aes(x=education, y=Wage))+
geom_boxplot(outlier.colour="red", outlier.shape=8, outlier.size=4)+labs(x="Nivel de estudio", y="Salario")
我制作了其他图形,但是仅使用了数字变量,可能的问题是现在我正在使用分类变量。有什么想法吗?在此先感谢智利的问候。