I am a new user in R and now I have a question. I have a numeric object like:
QSW<- as.numeric(c(1:50))
This vector is the input of my function defined as:
HAR_ReCov<-function(vec){
x<-vec
ReCov_d = ReCov_w = ReCov_m = NULL
TT = length(x)
for (i in 30:TT){
ReCov_d[i] = x[(i-1)]
ReCov_w[i] = sum(x[(i-7):(i-2)],na.rm = T)/6
ReCov_m[i] = sum(x[(i-29):(i-8)],na.rm = T)/22
}
return = cbind(ReCov_d, ReCov_w, ReCov_m)
}
I want to know how can concatenate the name of my vector QSW
with the names of my new variables, such that the names of the outputs be ReCoV_d_QSW
, ReCoV_w_QSW
, ReCoV_m_QSW
.
Thanks for your help.