Let's say I need to do this:
foo <- list(`a+b` = 5)
but I have 'a+b'
(a string) saved in a variable, let's say name
:
name <- 'a+b'
How to create that list with an element whose name is the value in the variable name
?
Note: I am aware of other ways of assigning names to elements of lists. The list here is just an example. What I want to understand is how I deal with non-standard evaluation so that I can indicate to a function the named argument without having to type it directly inline.
I have read Hadley's Advanced R Chapter 13 on Non-standard evaluation but I am lost on how to do this still.
Any solution with base R or Tidy Evaluation is appreciated.