cbind a dataframe with an empty dataframe - cbind.fill?

后端 未结 9 1670
野的像风
野的像风 2020-11-22 11:25

I think I\'m looking for an analog of rbind.fill (in Hadley\'s plyr package) for cbind. I looked, but there is no cbind.fill

9条回答
  •  失恋的感觉
    2020-11-22 11:56

    While, I think Tyler's solution is direct and the best here, I just provide the other way, using rbind.fill() that we already have.

    require(plyr) # requires plyr for rbind.fill()
    cbind.fill <- function(...) {                                                                                                                                                       
      transpoted <- lapply(list(...),t)                                                                                                                                                 
      transpoted_dataframe <- lapply(transpoted, as.data.frame)                                                                                                                         
      return (data.frame(t(rbind.fill(transpoted_dataframe))))                                                                                                                          
    } 
    

提交回复
热议问题