On Jan 31, 2011, at 8:45 PM, Gundala Viswanath wrote:

Dear sirs,

I have a data that is generated like this:

dat1 <- data.frame(V1 = rep(1, 5), V2 = sample(c(40:45), 5))
dat2 <- data.frame(V1 = sample(c(0,1), 5, replace = TRUE), V2 = sample(c(40:45), 5, replace = TRUE))

What I want to do is to obtain a data frame that contain list of list.

hiv
$hiv.dat1
$hiv.dat1$V1[[1]]
[1] 1 1 1 1 1

$hiv.dat1$V2[[1]]
[1] 41 42 43 40 44


$hiv.dat2
$hiv.dat2$V1[[1]]
[1] 0 1 1 0 0

$hiv.dat2$V2[[1]]
[1] 42 43 40 44 43

But why this line of command failed to create that?

hiv <- list(hiv.dat1 = as.list(dat1), hiv.dat2 = as.list(dat2))

Especially it gives  "$hiv.dat1$V1" instead of "$hiv.dat1$V1[[1]]".

But that _is_ a list of lists. Two lists, each with two sub-lists

 hiv$hiv.dat1$V1[[1]] is just the element "1". It is not a list.



How can we correct that?
I need this particular data structure required for a specific package (ROCR).

To do what operation or procedure?



--

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to