df lists

Upload: aiwenwong2428

Post on 04-Feb-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/21/2019 Df lists

    1/1

    Dataframe is a list of vectors of usually different types, but of the same length.

    > l = list(c(1,2,3), c("a","b","c"), c(TRUE,FALSE,TRUE))> l[[1]][1] 1 2 3

    [[2]][1] "a" "b" "c"

    [[3]][1] TRUE FALSE TRUE

    > d = data.frame(num = c(1,2,3), label = c("a","b","c"), flag = c(TRUE, FALSE, TRUE))> d num label flag1 1 a TRUE2 2 b FALSE3 3 c TRUE

    > as.list(d)

    $num[1] 1 2 3

    $label[1] a b cLevels: a b c

    $flag[1] TRUE FALSE TRUE

    > as.data.frame(l) c.1..2..3. c..a....b....c.. c.TRUE..FALSE..TRUE.1 1 a TRUE

    2 2 b FALSE3 3 c TRUE

    > typeof(l)[1] "list"

    > typeof(d)[1] "list"