Friday, November 11, 2016

R: list vs. (c)ombine

list vs. (c)ombine

(Lists can hold different types of objects; keeps them distinct.)




> mylist = list(x=1:5, y=c("a", "b", "c"), z=c(T,F,T))
> mylist
$x
[1] 1 2 3 4 5

$y
[1] "a" "b" "c"

$z
[1]  TRUE FALSE  TRUE

> mycombine = c(x=1:5, y=c("a", "b", "c"), z=c(T,F,T))
> mycombine
     x1      x2      x3      x4      x5      y1 
    "1"     "2"     "3"     "4"     "5"     "a" 
     y2      y3      z1      z2      z3 
    "b"     "c"  "TRUE" "FALSE"  "TRUE" 


 
 

No comments:

Post a Comment