对具有相同值的列进行过滤 [英] r filtering for columns with equal values

查看:109
本文介绍了对具有相同值的列进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有一个这样的数据集

pre $ v $ v $ v $
x 123 123 x
x 123 456 x
x 789 789 x
x 123 789 x`

是否过滤,以便只有第7列和第8列的值相等的行被拉出, WHILE STILL 在过滤之后保留列的标题?我试过这段代码:

hg19 - > hg19 [其中(hg19 $ V7 == hg19 $ V8),]



和这段代码:

  non_coding = subset(hg19,hg19 [8] == hg19 [7])

其中hg19是数据集。 note :真正的数据集有超过99,000行和16列

解决方案

  non_coding<  -  subset(hg19,hg19 $ v7 == hg19 $ v8)


lets say i have a data set like this

`v6 v7   v8  v9
x  123  123  x
x  123  456  x
x  789  789  x
x  123  789  x `   

how do I filter so that only the rows in which the values for columns 7 and 8 are equal to each other are pulled out, WHILE STILL keeping the header for the columns after the filtering? i've tried this code:

hg19 -> hg19[which(hg19$V7 == hg19$V8),]

and this code:

non_coding= subset(hg19,hg19[8] == hg19[7])

where hg19 is the data set. note: the real data set has over 99,000 rows and 16 columns

解决方案

non_coding <- subset(hg19, hg19$v7 == hg19$v8)

这篇关于对具有相同值的列进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆