r - concatenating strings to make variable name -
i want change name of output of r function reflect different strings inputted. here have tried:
kd = c("a","b","d","e","b") test = function(kd){ return(list(assign(paste(kd,"burst",sep="_"),1:6))) }
this simple test function. warning (which bad error me):
warning message: in assign(paste(kd, "burst", sep = "_"), 1:6) : first element used variable name
ideally ouput a_burst = 1, b_burst = 2 , on not getting close.
i split dataframe contents of vector , able name according name vector, similar
how split data frame rows, , process blocks?
but not quite. naming imperative.
something this, maybe?
kd = c("a","b","d","e","b") test <- function(x){ l <- as.list(1:5) names(l) <- paste(x,"burst",sep = "_") l } test(kd)
Comments
Post a Comment