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
--
Do all you can with what you have in the time you have in the place you are!
-Nkosi Johnson, 12-year old African hero
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/
try this:
results.pas <- results[results$Score != "Failed", ]
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Bernard L. Dillard" <bld at math.umd.edu>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, June 20, 2005 5:15 PM
Subject: [R] Data Parsing
> 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
>
> --
> Do all you can with what you have in the time you have in the place
> you are!
>
> -Nkosi Johnson, 12-year old African hero
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>