首页 > 解决方案 > Computing histogram of particular column variable in R

问题描述

So I'm interested in making a histogram of values just for the "NV" variable (the column contains either "NV" or "VV".) How can I extract just these particular values?

enter image description here

标签: rhistogram

解决方案


由于您没有提供可重现的示例:

虚拟数据

df <- data.frame(id=c(rep("NV",15),rep("VV",15)),value=sample(x = 1:100,size = 30,replace = TRUE))

通过对所需值进行子集化来创建直方图

hist(df[df$id=="NV",]$value)

或者

hist(df[df$id=="NV",2])

推荐阅读