r - Creating a dataframe from another one by column values -


i have following dataframe (df1)

> df1   var1 var2 var3 df2 1   ac   bc   bc  0 2   bc   bc   cc  1 3   dc   ec   dc  1 4   gc   gc   gc  0 

i new dataframe (df2) contain values of 1 in column df2. df2 followed:

> df2       var1 var2 var3       2   bc   bc   cc       3   dc   ec   dc  

how can it?

subset should work:

df2 <- subset(df1, df2 !=0) df2 <- df2[,1:3] df2 #var1 var2 var3 #2   bc   bc   cc #3   dc   ec   dc 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -