Mohammad
Mohammad

Reputation: 133

How to write subset function for object by logical class in R

I have an object in R include gene_name and their value(TRUE/FALSE) such as below:

    TSPAN6           TNMD           DPM1          SCYL3       C1orf112            

     TRUE            FALSE          FALSE          FALSE           TRUE           

     FUCA2            GCLC          NFYA          STPG1          NIPAL3             

      TRUE           FALSE          FALSE          TRUE           FALSE            

The class of object is "logical". My object name is "rest" and I want to get subset from "rest" include just gene name that their value is TRUE. I write my code in R language.

Upvotes: 0

Views: 84

Answers (1)

Newl
Newl

Reputation: 330

If I understand your question properly, you can do that simply by

rest[rest == TRUE]

or if you want to know the names:

names(rest[rest == TRUE])

Upvotes: 1

Related Questions