I've just a simple question regarding to case, that I want to use a character as an argument of a self created function.
I have three time series sets. Lets say a_ts, b_ts and c_ts and I want to merge a or b with c, depending on the funcion Input.
foo <-function(type){
total_series <- rbind(type_ts,c_ts)
return(total_series)
}
with type as type="a", type="b".
Lets say I dont want to change the character names. How can I solve the Problem, that a isnt printed in quotes in the function.
I want rbind(a_ts,c_ts) or rbind (b_ts,c_ts) without the quotes around my character argument.
Thanks for helping.
If I understand you correctly, something like this is what you need:
foo <- function(obj1, type) {
obj2 <- paste0(type, "_ts")
total_series <- rbind(obj1, get(obj2, envir = .GlobalEnv))
return(total_series)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.