I have this code:
library(magrittr)
a <- function(cars) return(cars)
b <- function(x) return(list(varname = deparse(substitute(x)), content = x))
b(cars) returns a list with the string cars and the content of the data.frame cars.
Any way to get a(cars) %>% b() to also return the string cars (the name of the variable returned by the function a()) and the content of the data.frame?
Instead, it returns . and the content of the data.frame.
That is, I would like the second function to return the name of the variable returned by the first function as well as the content of the variable.
What I actually want to do with b() is something like write.csv(x, paste0(deparse(substitute(x)), ".csv")).
Any suggestions?