[R] Data Parsing

Roger D. Peng rpeng at jhsph.edu
Mon Jun 20 17:27:38 CEST 2005


You can use 'subset()' if you have a data frame.

d <- read.table(...)
subset(d, Score %in% c("Passed", "Borderline"))

-roger

Bernard L. Dillard wrote:
> Hello.  I have looked at R Site Search for this problem, and it didn't
> give me exactly what I needed.
> 
> Consider this dataset called "results".  It has the following information:
> 
> Student      Day        Subject        Score
> 
> Mary          1          Math          Failed
> David         2          Science       Passed
> Bob           4          Reading       Passed
> Marie         4          Reading       Failed
> Jesse         3          Spelling      Borderline
> Et cetera
> 
> 
> My goal is to only do analysis of the data having to do those who passed
> or who are borderline.  I want to ignore all of the data having to do with
> those who failed.  I think part of the syntax is something like
> results[-c("Failed")], but I'm not getting anywhere with it.
> 
> How do I create a separate data set containing all information on students
> who either passed or were borderline?
> 
> Thanks.
> 
> Bernard
> 

-- 
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/




More information about the R-help mailing list