r - Select columns containing a value above a threshold -


i have following dataset

df<-data.frame(c(1,2,1),c(2,1,3), c(1,3,4)) 

let want select columns contain value equal or higher 3 (i.e columns 2 , 3)

i managed to find logical argument using df >= 3 , index which(df>=3) struggle selecting columns.

filter seems option here:

df <- data.frame(x = c(1,2,1), y = c(2,1,3), z = c(1,3,4))  filter(   function(x) max(x) >= 3,   df   ) 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -