you could try something along these lines:
dat <- data.frame(x = rnorm(100),
y = sample(letters, 100, TRUE),
z = sample(LETTERS, 100, TRUE),
w = runif(100),
k = rexp(100, 2),
m = rep(c("yes", "No"), 50))
###################
index <- lapply(seq(1, ncol(dat), 2), seq, length = 2)
list.dat <- lapply(index, "[", x = 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 "Walter R. Paczkowski" <dataanalytics@earthlink.net>:
>
>
> Hi,
>
>
> Suppose I have a data frame with n rows and six columns. I want to
> create a list that has, say, 3 components each with all n rows but
> with
> the first having the first two columns of the original data frame,
> the
> second component having the next two columns, and the third having
> the
> last two columns. SPLIT doesn't work since it splits the
> rows. I want to split the columns. Transpose doesn't work
> that I can see. Any suggestions?
>
>
> Thanks,
>
>
> Walt Paczkowski
>
>
>
> _________________________________
>
>
> Walter R. Paczkowski, Ph.D.
>
> Data Analytics Corp.
>
> 44 Hamilton Lane
>
> Plainsboro, NJ 08536
>
> (V) 609-936-8999
>
> (F) 609-936-3733
>
>
>
>
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
|