内容简介:翻译自:https://stackoverflow.com/questions/12204171/fast-way-to-select-rows-within-table-in-r
我正在寻找一种从更大的表中提取大量行的快速方法.我的表顶部如下:
> head(dbsnp)
snp gene distance
rs5 rs5 KRIT1 1
rs6 rs6 CYP51A1 1
rs7 rs7 LOC401387 1
rs8 rs8 CDK6 1
rs9 rs9 CDK6 1
rs10 rs10 CDK6 1
尺寸:
> dim(dbsnp) [1] 11934948 3
我想选择列表中包含rownames的行:
> head(features) [1] "rs1367830" "rs5915027" "rs2060113" "rs1594503" "rs1116848" "rs1835693" > length(features) [1] 915635
毫不奇怪,执行此temptable = dbsnp [features,]的直接方式需要相当长的时间.
我一直在研究如何通过R中的sqldf包来实现这一点.我认为这可能会更快.不幸的是,我无法弄清楚如何在 SQL 中选择具有某些rownames的行.
谢谢.
大多数人最初尝试的方式是:
dbsnp[ rownames(dbsnp) %in% features, ] # which is probably slower than your code
因为你说这需要很长时间,我怀疑你已经超过你的RAM容量并开始使用虚拟内存.你应该关闭你的系统,然后只用R作为正在运行的应用程序重新启动,看看你是否可以避免“虚拟化”.
翻译自:https://stackoverflow.com/questions/12204171/fast-way-to-select-rows-within-table-in-r
以上所述就是小编给大家介绍的《sql – 在R中选择表中的行的快速方法?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Dreamweaver CS3 Bible
Joseph W. Lowery / Wiley / May 21, 2007 / $49.99
Book Description Learn to create dynamic, data-driven Web sites using the exciting enhancements in the Dreamweaver CS3 version. You get a thorough understanding of the basics and then progress to l......一起来看看 《Dreamweaver CS3 Bible》 这本书的介绍吧!