Skip to content

Instantly share code, notes, and snippets.

@teeler
Created March 14, 2012 20:06
Show Gist options
  • Save teeler/2039128 to your computer and use it in GitHub Desktop.
Save teeler/2039128 to your computer and use it in GitHub Desktop.
R WTF
# 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...
@teeler
Copy link
Author

teeler commented Mar 14, 2012

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)))

@MattNapsAlot
Copy link

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