pengyu.ut wrote:
> 
> I'm thinking of using external program 'grep' and pipe() to do so. But
> I'm wondering if there is a more efficient way to do so purely in R
> 

I would just suck the whole table in using read.table(), locate the lines
that I don't want using apply() and grepl() and then reduce the data set:

  dataSet <- read.table( "someData.txt" )

  dataToDrop <- apply( dataSet, 1, function( row ){

    return(
      any( grepl( "regex", row ) )
    )

  })

  dataSet <- subset( dataSet, !dataToDrop )

Since this solution executes entirely in R without resorting to system()
calls, it should be portable between platforms.

-Charlie
-- 
View this message in context: 
http://n4.nabble.com/How-to-exclude-lines-that-match-certain-regex-when-using-read-table-tp948207p948221.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to