[R] Parsing a data file - Help
A Ezhil
ezhil02 at yahoo.com
Wed Jun 11 19:29:24 CEST 2008
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
More information about the R-help
mailing list