I need to pass the name of a list as a string to a mutate column as part of a custom function. For e.g.:
a_list = c('a','b','c')
test = function(list_name) {
map_df(list_name, function(x) {
benchmark(x = paste(x,'test')) %>%
mutate(test = x,
list_name_as_string = deparse(substitute(list_name)))
})
}
test(a_list)
gives:
test replications elapsed relative user.self sys.self user.child sys.child list_name_as_string
1 a 100 0 NA 0 0 NA NA list_name
2 b 100 0 NA 0 0 NA NA list_name
3 c 100 0 NA 0 0 NA NA list_name
I want the last column to be "a_list" repeated.
THanks
a_lista list, but it is a vector, not alist(). Being careful with that terminology can help avoid headaches later.