Why cbind for ts objects behaves different from cbind for matrices and data.frames in R? -


does why result of following code different?

a <- cbind(1:10,1:10) b <- colnames(a) <- c("a","b") colnames(b) <- c("c","d")  colnames(cbind(a,b)) > [1] "a" "b" "c" "d" colnames(cbind(ts(a),ts(b))) > [1] "ts(a).a" "ts(a).b" "ts(b).c" "ts(b).d" 

is or compatibility reasons? cbind xts , zoo not have feature.

i accepted given, code littered following:

ca<-colnames(a) cb<-colnames(b) out <- cbind(a,b) colnames(out) <- c(ca,cb) 

this cbind.ts method does. can see relevant code via stats:::cbind.ts, stats:::.cbind.ts, , stats:::.makenamests.

i can't explain why made different, since didn't write it, here's work-around.

cbts <- function(...) {   dots <- list(...)   ists <- sapply(dots,is.ts)   if(!all(ists)) stop("argument ", which(!ists), " not ts object")   do.call(cbind,unlist(lapply(dots,as.list),recursive=false)) } 

Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -