字符串從表中的行,我想使用存儲在向量中的弦從表中刪除行:刪除基於在
> dput(vec_temp)
c("HL", "LL", "ML")
表看起來像這樣:
structure(list(Accession = "AT1G71220", variable = structure(14L, .Label = c("f:HL-f:FL",
"f:LL-f:FL", "f:ML-f:FL", "f:LL-f:HL", "f:ML-f:LL", "f:ML-f:HL",
"m:HL-m:FL", "m:LL-m:FL", "m:ML-m:FL", "m:LL-m:HL", "m:ML-m:HL",
"m:ML-m:LL", "ntrc:HL-ntrc:FL", "ntrc:LL-ntrc:FL", "ntrc:ML-ntrc:FL",
"ntrc:LL-ntrc:HL", "ntrc:ML-ntrc:HL", "ntrc:ML-ntrc:LL", "WT:HL-WT:FL",
"WT:LL-WT:FL", "WT:ML-WT:FL", "WT:LL-WT:HL", "WT:ML-WT:HL", "WT:ML-WT:LL"
), class = "factor"), value = 0.0445054204080209), .Names = c("Accession",
"variable", "value"), row.names = 2167L, class = "data.frame", na.action = structure(c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 15L, 16L,
17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L), .Names = c("35", "199",
"363", "527", "691", "855", "1019", "1183", "1347", "1511", "1675",
"1839", "2003", "2331", "2495", "2659", "2823", "2987", "3151",
"3315", "3479", "3643", "3807"), class = "omit"))
請關注在名爲variable
的列上。該表格包含一行variable
- >ntrc:LL-ntrc:FL
。從這個線程的開頭看矢量,我們可以看到FL
不在那裏。因此,我想刪除該行(通常是整個表格)。我想問R將向量中的字符串與存儲在名爲variable
的列中的字符串進行比較,這些列出現在:
之後。如果在向量中找不到表中的字符串,則應刪除整行(或表)。
所以既'LL'和「FL」應該在向量中以便不被刪除? – Sotos
他們應該在那個向量中。順序無關緊要。正如你看到'FL'不在那裏。 – tralala
您只顯示了單個行數據集。請包括更多行 – akrun