I'm looking to take a dataset and look through one column to say: "if this one variable == "true", then add the row to dataset1. Else, add it to dataset2".
Asked
Active
Viewed 117 times
0
-
Can you show an example to test – akrun Mar 16 '21 at 23:02
-
Sure. Lets say you had 2 rows. ``` Col1 Col2 0 1 1 1 0 0 1 0 ``` I would want to take all the rows in which Col1 == 1 and put it into a data set and put all rows where Col1==0 and put it in another dataset – DistantOven Mar 16 '21 at 23:45
1 Answers
0
We can use subset
df1 <- subset(df_full, Col1 == 1)
df0 <- subset(df_full, Col1 == 0)
Or with split
into a list
lst1 <- split(df_full, df_full$Col1)

akrun
- 874,273
- 37
- 540
- 662