r - Optimize a code combining title of a list -


i have list factor.lst composed of 16 elements. each element of list vector of characteres. obtain new vector of size [1:16] composed combinaison of each charactere string. manage obtain want using :

col.titles <- c(paste(factor.lst[[1]], collapse=" "), (paste(factor.lst[[2]], collapse=" ") ... (paste(factor.lst[[16]], collapse=" "))) 

but that's lot of line reach 16 ! how can call list directly instead of each element within list ? thinking of that's not working.

col.titles <- c(paste(factor.lst[[1:16]], collapse=" ")) 

sapply apply function each element of object, can use apply paste(x, collapse=' ') each element of factor.lst.

try:

sapply(factor.lst, paste, collapse=' ') 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -