Created
March 14, 2012 20:06
-
-
Save teeler/2039128 to your computer and use it in GitHub Desktop.
R WTF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ok, so appending items to lists. | |
# I'm fine with this. | |
f <- list() | |
f <- c(f, 1) | |
f <- c(f, 2) | |
f <- c(f, 3) | |
# Ok, lets try something fancier, lists of lists. | |
f <- list() | |
f <- c(f, list(a=1)) | |
f <- c(f, list(a=2)) | |
f <- c(f, list(a=3)) | |
j <- list(list(a=1), list(a=2), list(a=3)) | |
# I'd expect f == j at this point, but it doesnt, and i dont understand what the hell F is... |
I also discovered this:
f <- c(f, list(list(a=1)))
f <- c(f, list(list(a=2)))
f <- c(f, list(list(a=3)))
No surprise there. that's exactly what I'd expect. You keep concatenating the ever-growing list multiple times with itself.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is one way to accomplish that: