Re: [R] dividing the data

From: Marianne Promberger <mpromber_at_psych.upenn.edu>
Date: Fri, 23 May 2008 23:02:23 +0100

On 05/23/08 14:34, kayj wrote:
>
> hello,
>
> I have data of individuals; with their age and other infromation. Each row
> corresponds to a single individual. I would like to divide the data and
> store them into two files. one file with people less than 50 years of age
> and the other with people more than 50 years of age.

Assuming you have your data in a dataframe x with one column called "age" (get the data into R e.g. with read.csv)

young <- x[x$age < 50,]

write.table(young,file="young.txt")

etc.

m.

-- 
Marianne Promberger
Graduate student in Psychology
http://www.psych.upenn.edu/~mpromber

______________________________________________
R-help_at_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.
Received on Fri 23 May 2008 - 22:06:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 23 May 2008 - 23:30:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive