简体   繁体   English

绘图数据-R中的boxplot如何删除NA

[英]plot data - boxplot in R how to remove NAs

I have a data table of university data. 我有大学数据的数据表。 We are looking at successes 1 against failures 0 where successes are completed. 我们将成功1与失败0视为成功完成。

There are about 5000 observations and 65 variables. 大约有5000个观测值和65个变量。

I have a heap of NAs in the success column. 成功列中有大量NA。 When I try to plot against the other data the NAs keep appearing as a category in my boxplot alongside the 1s and 0s. 当我尝试针对其他数据进行绘制时,NA在我的箱图中始终显示为1和0旁边的类别。

The code I am currently using is: 我当前使用的代码是:

plot(WAM ~ success,data=na.omit(students), main="Boxplot: success and WAM")

The data is in data.table. 数据在data.table中。 Any advice on how to plot the 1 and 0s only? 关于如何仅绘制1和0的任何建议?

Use ggplot: 使用ggplot:

library(ggplot2)    
ggplot(students) + geom_boxplot(aes(x = success, y = WAM))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM