Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Selects the row in the data frame that contains a specific value

$
0
0

I have a data.frame like list.1,I want to select the row from list.1, which contain the value of c(101,102,103,104), to create a new data.frame list.2.
list.1

#  ID      col1       col2     col3
#1 1       101        102      201
#2 2       201        202      203
#3 3       104        NA       301
#4 4       101        NA        NA
#4 5       201        301      302

The result I want is:

list.2

#  ID     col1       col2     col3
#1 1       101        102      201
#2 3       104        NA       301
#3 4       101        NA        NA

Then the next I want is: Only contain the value of c(101,102,103,104) from list.2 ,but all put in one column
list.3

#  ID     col1       
#1 1       101
#2 1       102
#3 3       104
#4 4       101

Many Thanks!


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>