第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

用一個(gè)空的dataframe-cbine.fill綁定一個(gè)dataframe?

用一個(gè)空的dataframe-cbine.fill綁定一個(gè)dataframe?

慕尼黑8549860 2019-07-16 10:13:23
用一個(gè)空的dataframe-cbine.fill綁定一個(gè)dataframe?我想我在找一個(gè)模擬的rbind.fill(在Hadley‘splyr(包裝)cbind..我看過了,但沒有cbind.fill.我想做的是:#set these just for this exampleone_option <- TRUEdiff_option <- TRUEreturn_df <- data.frame()if (one_option) {     #do a bunch of calculations, produce a data.frame, for simplicity the following small_df     small_df <- data.frame(a=1, b=2)     return_df <- cbind(return_df,small_df)}if (diff_option) {     #do a bunch of calculations, produce a data.frame, for simplicity the following small2_df     small2_df <- data.frame(l="hi there", m=44)     return_df <- cbind(return_df,small2_df)}return_df可以理解,這會(huì)產(chǎn)生一個(gè)錯(cuò)誤:Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 0, 1我現(xiàn)在的修復(fù)方法是替換線路return_df <- data.frame()帶著return_df <- data.frame(dummy=1)然后代碼就能工作了。然后,我只需從return_df最后。在添加虛擬代碼并運(yùn)行上述代碼之后,我得到      dummy a b        l  m1     1 1 2 hi there 44然后我只需要處理掉假人,例如:> return_df[,2:ncol(return_df)]   a b        l  m1 1 2 hi there 44我肯定我錯(cuò)過了一個(gè)更簡單的方法來做這件事。編輯:我想我不是在找Cbinn,因?yàn)檫@意味著安娜的值將在cbind之后創(chuàng)建,這不是我想要的。
查看完整描述

3 回答

?
慕沐林林

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊

但是,我認(rèn)為泰勒的解決方案是直接和最好的,我只是提供了另一種方式,使用rbind.fill()我們已經(jīng)有了。

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))))


查看完整回答
反對 回復(fù) 2019-07-16
?
江戶川亂折騰

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊

使用rowr::cbind.fill


rowr::cbind.fill(df1,df2,fill = NA)

   A B

1  1 1

2  2 2

3  3 3

4  4 4

5  5 5

6 NA 6


查看完整回答
反對 回復(fù) 2019-07-16
  • 3 回答
  • 0 關(guān)注
  • 838 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號