过滤数据框中的值 [英] Filter values in data frame

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

问题描述

基本上,我有一个基因数据集,其中行是基因,列是蛋白质折叠的连续时间点。我需要一个函数来过滤整个数据集中某个阈值的基因,而不仅仅是某些向量。例如:

  alpha98 alpha105 alpha112 alpha119 
YAL002W 0.22 0.58 -0.36 0.13
YAL003W 0.05 0.55 -0.08 0.33

任何帮助都会很棒。

解决方案

R 是矢量化的, R 这意味着,一般来说,就像 myDF>阈值会让你非常接近你所需要的。

具体来说,它会为您提供与您的数据具有相同维度的逻辑矩阵 .frame 当DF中的单元格超过阈值( FALSE )时, TRUE 否则)。

然后,您可以使用该矩阵作为工具来对数据进行子集化。

  myDF [myDF>阈值] 


Basically, I have a gene dataset in which the rows are genes and columns are sequential time points of protein folding. I need a function to filter genes of a certain threshold value from others across the entire data set, not just for certain vectors. For example:

          alpha98 alpha105 alpha112 alpha119
YAL002W      0.22     0.58    -0.36     0.13
YAL003W      0.05     0.55    -0.08     0.33

Any help would be great.

解决方案

R is vectorized and R recycles. That means, that generally, something as simple as myDF > threshold will get you awfully close to what you need.

Specifically, it will give you a logical matrix of the same dimensions as your data.frame which will be TRUE when that cell in the DF exceeds the threshold (and FALSE otherwise).

You can then use that matrix as your tool to subset the data.frame.

myDF[myDF > threshold]  

这篇关于过滤数据框中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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