美文网首页数据科学与R语言
R - 几种数据集筛选的速度

R - 几种数据集筛选的速度

作者: XuXiaolu | 来源:发表于2018-08-24 14:26 被阅读0次

用了一份很大的数据集,进行条件筛选:

t0 = Sys.time()
cprv_GM[cprv_GM$is_turbo == '非增压',]  
Sys.time() - t0  # Time difference of 34.91563 secs
t0 = Sys.time()
filter(cprv_GM, is_turbo == '非增压') 
Sys.time() - t0  # Time difference of 35.17037 secs
t0 = Sys.time()
subset(cprv_GM, is_turbo == '非增压') 
Sys.time() - t0  # Time difference of 34.67368 secs

结语:

其实三种方法差距并不大,但还建议优先选择subset的方法。

相关文章

网友评论

    本文标题:R - 几种数据集筛选的速度

    本文链接:https://www.haomeiwen.com/subject/biibiftx.html