[R] dividing the data

Marianne Promberger mpromber at psych.upenn.edu
Sat May 24 00:02:23 CEST 2008


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



More information about the R-help mailing list