xfun <- function(yvar, newvar){
df %>%
pull(yvar) %>%
lmoms(., nmom=4) %>% # Estimates some parameters
{. ->> newvar} # Stores list
}
xfun("var2", "newvar2")
But this doesn't work. I get new output.
But this works:
xfun <- function(yvar){
df %>%
pull(yvar) %>%
lmoms(., nmom=4) %>% # Estimates some parameters
{. ->> "newvar2"} # Stores list
}
xfun("var2")
So, how can I pass the newvar as a function argument to store this intermediate output?
Open to a different way of accomplishing this as well.