Unable to filter database using dplyr::select

First I read in my data with:

gtf <- rtracklayer::readGFF('ref/gencodev25.gtf')

No problem there...then I filtered rows with:

txdb <- dplyr::filter(gtf,type=='transcript')

No problem there either...then I attempted to filter columns with:

> txdb_b <- dplyr::select(transcript_id, gene_name)
Error in dplyr::select(transcript_id, gene_name) : 
  object 'transcript_id' not found

I googled solutions. Concensus seemed to be that problem might be a conflict with another package that uses 'select' as a function. However, as I point to the package in the code I use (i.e., dplyr::select), guess that is probably not the issue?

RStudio: Version 1.1.453
dplyr: Version

P.S. Relatively new to R and coding.

You probably want this line to be:

> txdb_b <- dplyr::select(txdb, transcript_id, gene_name)

Also, you can chain your actions with %>% and this error is less likely to happen since txdb would be passed into dplyr::select.

1 Like

Thank you! The line you give solved my problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.