我無法使用名稱作爲變量運行的真棒tidyr complete()函數。使用內置的例子:tidyr complete()以變項名作爲變量
df <- data_frame(
group = c(1:2, 1),
item_id = c(1:2, 2),
item_name = c("a", "b", "b"),
value1 = 1:3,
value2 = 4:6
)
df %>% complete(group, nesting(item_id, item_name))
...按預期工作
gr="group"
id="item_id"
name="item_name"
df %>% complete_(gr, nesting_(id, name),fill = list(NA))
...但不會引發錯誤,但沒有工作,要麼
任何幫助表示讚賞!
根據源代碼, 'nesting_'只有一個參數(一個列表)。 –
是否應該扔箭頭,我想知道? –
@David Arenburg:當fill = list(NA)缺失時它會這樣做 – ChriiSchee