制作由名义组分隔的布尔值的直方图

时间:2022-05-22 14:57:29

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. I did a cross join to see if these TF factors fall in a particular series of ranges of data. Whether or not their center_points (median) fall in that range is designated by a boolean values in the falls.in.range column. 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.

列V4中有四个名义变量是转录因子。我做了一个交叉连接,看看这些TF因子是否属于一系列特定的数据范围。它们的center_points(中位数)是否落在该范围内由falls.in.range列中的布尔值指定。我希望生成一个直方图,其中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值?

1 个解决方案

#1


1  

Hist works for a numeric vector

Hist适用于数字向量

hist(df$V4[df$falls.in.range==True])

but this wont work as df$V4 isnt numeric. What you want is barplot rather than a histogram

但这不会起作用,因为df $ V4不是数字。你想要的是条形图而不是直方图

barplot(table(df$V4[df$falls.in.range==True]))

#1


1  

Hist works for a numeric vector

Hist适用于数字向量

hist(df$V4[df$falls.in.range==True])

but this wont work as df$V4 isnt numeric. What you want is barplot rather than a histogram

但这不会起作用,因为df $ V4不是数字。你想要的是条形图而不是直方图

barplot(table(df$V4[df$falls.in.range==True]))