jeromyanglim / learning_r

assorted notes to self while learning R
1 stars 0 forks source link

Quick way to generate a list with named elements corresponding to name in code? #3

Open jeromyanglim opened 12 years ago

jeromyanglim commented 12 years ago

e.g.,

I have a function

myfunction <- function() {
     a <- 1
     b <- 2
}

How do I generate: list(a=a, b=b)

Clearly, in this simple example, it is easy to type, but what if the names were longer, and there were many names, this would be more fiddly. What is a good way of doing this?