[英]Making a histogram of boolean values separated by nominal groups
Currently I have a dataset like this: 目前,我有一个像这样的数据集:
X observation.ID range.ID Center_Point range.low range.high falls.in.range V4
1: 1 1 242601532 11323785 11617177 FALSE KLF4
2: 1 2 242601532 12645605 13926923 FALSE KLF4
3: 1 3 242601532 14750216 15119039 FALSE KLF4
4: 1 4 242601532 18102157 19080189 FALSE KLF4
5: 1 5 242601532 29491029 30934636 FALSE KLF4
---
13558714: 83 1 7974990 2940166 7172793 FALSE OCT4
13558715: 83 2 7974990 7880008 13098461 TRUE OCT4
13558716: 83 3 7974990 13556427 13843364 FALSE OCT4
13558717: 83 4 7974990 14113371 15137286 FALSE OCT4
13558718: 83 5 7974990 15475619 19472504 FALSE OCT4
There are four nominal variables in column V4 that are transcription factors. 在第V4列中有四个标称变量是转录因子。 I did a cross join to see if these TF factors fall in a particular series of ranges of data. 我进行了交叉联接,以查看这些TF因子是否属于特定系列的数据范围。 Whether or not their center_points (median) fall in that range is designated by a boolean values in the falls.in.range column. 它们的center_points(中间值)是否落在该范围内,由falls.in.range列中的布尔值指定。 I am looking to generate a histogram where the x-axis is the four transcription factors (V4) and the y- axis is the frequencies of them falling in the set ranges I am checking. 我希望生成一个直方图,其中x轴是四个转录因子(V4),y轴是它们在我检查的设定范围内的频率。
How would I take into account the true vs. false values in the falls.in.range column when generating a histogram? 生成直方图时,如何考虑falls.in.range列中的true和false值?
Hist works for a numeric vector Hist适用于数值向量
hist(df$V4[df$falls.in.range==True])
but this wont work as df$V4 isnt numeric. 但这将无法工作,因为df $ V4不是数字。 What you want is barplot rather than a histogram 您想要的是条形图而不是直方图
barplot(table(df$V4[df$falls.in.range==True]))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.