0
與特徵向量一個tibble列我有兩個tibbles子集化從另一個tibble
>a.tibble
names other
a 0
c 0
d 0
>b.tibble
a b c d e
1 1 1 1 1
1 1 1 1 1
我想用names <- select(a.tibble,names)
於子集b.tibble
,使c.tibble
:
>c.tibble
a c d
1 1 1
1 1 1
重要的是,我的子集names
,因爲實際上我有很多名字來劃分一個大的骰子。這使得通常的select(b.tibble,-c(b,e))
或其他「手動」列名稱條目是不可能的。
數據
library(tibble)
a.tibble = tibble(names = c("a","c","d"), other = 0)
b.tibble = tibble(a = rep(1,2), b = 1, c = 1, d = 1, e = 1)
'b.tibble答案[在%,名稱(b.tibble)%a.tibble $名]' – ytk
我不't不知道'tibble'的行爲如何,但是這適用於data.frame'b.tibble [as.character(a.tibble $ names)]' –
'b.tibble%>%select _(。dots = a。 tibble $ name)'似乎是這樣,儘管這似乎不是一種有效的解決方式。 – Frank