更新时间:2023-01-17 20:07:35
有几种不同的方法可以做到这一点.我更喜欢使用 apply
,因为它很容易扩展:
There are a few different ways of doing this. I prefer using apply
, since it's easily extendable:
##Generate some data
dd = data.frame(a = 1:4, b= 1:0, c=0:3)
##Go through each row and determine if a value is zero
row_sub = apply(dd, 1, function(row) all(row !=0 ))
##Subset as usual
dd[row_sub,]