![](/img/trans.png)
[英]How do I remove specified rows from a data frame in R, but the rows are eliminated according to another column variable?
[英]In R, how do I delete rows in a data frame by column names of another data frame?
數據:
df1 <- data.frame(a = 1:3, b = 1:3)
# a b
# 1 1 1
# 2 2 2
# 3 3 3
df2 <- data.frame(col1 = c("a", "c"))
# col1
# 1 a
# 2 c
保留df2
的行,其值為df1
中的名稱:
subset(df2, col1 %in% names(df1))
# col1
# 1 a
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.