Skip to content
Prev 374658 / 398513 Next

Convert a list of $NULL into multiple dataframes

Hi Ilio,
As far as I can see, this is what you have done:

A<-data.frame(V1="Year",V2=1992,V3=1993)
B<-data.frame(V1=c("Year","18-19"),V2=c("Average (cm)",178.3),
 V3=c("N",6309),V4=c("SD",6.39))
A
    V1   V2   V3
1 Year 1992 1993
B
     V1           V2   V3   V4
1  Year Average (cm)    N   SD
2 18-19        178.3 6309 6.39
# create "tables" from A and B
tables<-list("NULL"=A,"NULL"=B)
tables
$`NULL`
    V1   V2   V3
1 Year 1992 1993

$`NULL`
     V1           V2   V3   V4
1  Year Average (cm)    N   SD
2 18-19        178.3 6309 6.39
# recreate A by extracting the first element of "tables"
A<-tables[[1]]
A
    V1   V2   V3
1 Year 1992 1993
# recreate B by extracting the second element of "tables" minus the
fourth column
B<-tables[[2]][,-4]
B
B
    V1           V2   V3
1  Year Average (cm)    N
2 18-19        178.3 6309

Jim

On Fri, May 18, 2018 at 6:37 PM, Ilio Fornasero
<iliofornasero at hotmail.com> wrote:
Message-ID: <CA+8X3fX6YLHJw2YR75XQgZN1AG0k816jSx7i+-1igktkkHuMFQ@mail.gmail.com>
In-Reply-To: <AM4PR0802MB227542C79F4BD23C55B417A3B3900@AM4PR0802MB2275.eurprd08.prod.outlook.com>