[R] Parsing a data file - Help

From: A Ezhil <ezhil02_at_yahoo.com>
Date: Wed, 11 Jun 2008 10:29:24 -0700 (PDT)


Hi All,

I have the data in the following format:

idkt	saap		lahto		pidg
5266	19911111	19911114	3078A
5266	19921005	19921030	2968A
6666	19930208	19930209	3074A
6666	20020329	20020402	F322
6666	20020402	20020409	F322
6866	19810713	19810917	29800
6866	19811109	19811120	29550
6866	19820203	19820219	29550

I would like to parse the data and reformat into a single row for each unique idkt, something like:
5266  19911111	19911114 3078A 19921005	19921030 2968A

I have tried with

f <- read.table("file.txt", sep="\t", header=TRUE); attach(f);
fac <- factor(f[,1]);
id <- matrix(length(fac), 4);
for(i in fac) id[i] <- f[idkt %in% fac[i], ];

I am not able make the list id into a single row. Could you please help how I can do this?

Thanks in advance.

Kind regards,
Ezhil



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 Wed 11 Jun 2008 - 19:50:00 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 Wed 11 Jun 2008 - 20:32:19 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