You're right, it's not exactly what you wanted.

But... data.frames are lists, so you would access each element of it as you intended to:
HIV$hiv.dat1$predictions

My opinion is that it's easier to work with data.frames when possible (as opposed to lists), and I don't see why you would break down the columns of the data.frames. Plus you asked for nested data.frames. But maybe you do need to separate the columns of a data.frame, and you could do it like this:
HIV <- list(hiv.dat1=as.list(dat1), hiv.dat2=as.list(dat2))

HTH,
Ivan

Le 1/31/2011 15:31, Gundala Viswanath a écrit :
Hi Ivan,

Thanks for the reply.

Would that do?
But I won't do.

names(dat1)<- names(dat2)<- c("labels","predictions")
HIV<- list(hiv.dat1=dat1, hiv.dat2=dat2)

The above snippet produces this instead:

names(dat1)<- names(dat2)<- c("labels","predictions")
HIV<- list(hiv.dat1=dat1 hiv.dat2=dat2);

print(HIV)
$hiv.dat1
   labels predictions
1      1          43
2      1          43
3      1          43

$hiv.dat2
   labels predictions
1      1          43
2      1          21
3      1          43
4      1          43
5      1          24
6      0          24


- G.V.

Ivan


Le 1/31/2011 10:50, Gundala Viswanath a écrit :
Dear Experts,

I have a data that looks like this.

file1="dat1.tab"
file2="dat2.tab"
dat1<-read.table(file1)
print(dat1)
   V1 V2
1  1 43
2  1 43
3  1 43
dat2<-read.table(file2)
print(dat2)
   V1 V2
1  1 43
2  1 21
3  1 43
4  1 43
5  1 24
6  0 24
The column V1 refer to labels and V2 to prediction score.

How can I create a data structure called HIV, that looks like this:

HIV
$hiv.dat1
$hiv.dat1$predictions
$hiv.dat1$predictions[[1]]
[1] 43 43 43
$hiv.dat$labels
$hiv.dat$labels[[1]]
[1] 1 1 1

$hiv.dat2
$hiv.dat2$predictions
$hiv.dat$predictions[[1]]
[1] 43 21 43 43 24 24
$hiv.dat2$labels
$hiv.dat2$labels[[1]]
[1] 1 1 1 1 1 0

Forgive me I am a newbies here.

- G.V.

______________________________________________
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.

--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

______________________________________________
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.


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

______________________________________________
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