[R] Data manipulation
Dimitris Rizopoulos
Dimitris.Rizopoulos at med.kuleuven.be
Sat Sep 29 14:03:36 CEST 2007
use something like the following (untested)
files <- paste("C:/d", 1:3, ".txt", sep = "")
dats <- vector("list", 3)
for (i in 1:3) {
dats[[i]] <- read.table(files[i], header = TRUE)
}
dats
do.call("rbind", dat)
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/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
Quoting Stefo Ratino <sratino at yahoo.com>:
> Hello,
>
> I am beginner in R and I would like to solve the following problem:
> Suppose that we have three files to be red in R d1, d2, and d3
>
>> d1
> id x1 x2
> 1 1 4 n
> 2 2 3 h
> 3 3 0 f
>> d2
> id x1 x2
> 1 1 2 r
> 2 2 3 u
> 3 3 1 f
>> d3
> id x1 x2
> 1 1 2 a
> 2 2 1 w
>
> Is there any library or function that one can read this datasets like
> for(i in 1:3)
> d[i] <- read.table(file=d[j].txt, header=T)
>
> and is it possible to delete the header for each file and to have
> them in one data frame like
>
>> d
> 1 1 4 n
> 2 2 3 h
> 3 3 0 f
> 4 1 2 r
> 5 2 3 u
> 6 3 1 f
> 7 1 2 a
> 8 2 1 w
> 9 3 1 f
>
> I really appreciate your help!
> Stefo
>
>
>
>
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list