Skip to content
Back to formatted view

Raw Message

Message-ID: <AANLkTinW_omFc3sO_2mDTuKkK5-NPsy96q8ceAAG1_i7@mail.gmail.com>
Date: 2011-01-31T09:50:49Z
From: Gundala Viswanath
Subject: How to Create Nested Data Frame

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.