3

This is a fairly basic question. I want to define a list in R. The names of this list are to be the same names of the vectors that were used to create a list.

Better to write a short code example. This is what I want.

But using the same names twice in the list of arguments seems a really clumsy way of doing this!

vct_numbers <- c(1,2,3,4)
vct_colours <- c("blue", "green", "yellow")
lst_coll <- list(vct_numbers = vct_numbers, vct_colours  = vct_colours)

Is there a better / more elegant way of doing this...?

1
  • 1
    You've got the best way. Any other way to do it would require a lot of nonstandard evaluation and additional coding. Your code would be less readable to other R users in any other method. Commented Dec 18, 2015 at 2:22

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.