[英]How do I selectively visualize data in a categorical column in R?
I have a dataset with "Status" as one of its columns.我有一个以“状态”作为列之一的数据集。 In the status variable, the data is either "Employed" or "Left."
在状态变量中,数据为“已就业”或“已离职”。
I want to visualize only the "Left" entries of the "Status" column.我只想可视化“状态”列的“左”条目。
Currently, I'm only able to visualize both "Employed" and "Left" using this code:目前,我只能使用以下代码可视化“已就业”和“左”:
ggplot(data=employee_data) + geom_point(aes(x=satisfaction, y=last_evaluation, color=status))
If I want to isolate only those in "Left" category, how do I do that?如果我只想隔离“左”类别中的那些,我该怎么做?
This is done with a simple filter.这是通过一个简单的过滤器完成的。
ggplot(data = filter(employee_data, status == "left")) +
geom_point(aes(x = satisfaction, y = last_evaluation, color = status))
Using the iris dataset, you can see the output使用 iris 数据集,可以看到 output
ggplot(data = filter(iris, Species == "setosa")) +
geom_point(aes(x = Petal.Width, y = Petal.Length, color = Species))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.