作者k97231 (AL)
看板R_Language
標題[問題]match找不到數值
時間Wed Jun 27 16:44:41 2018
這是一段來自於github上的一段程式碼
其中samples=c("A_r","A_ir","B_r","B_ir",...)
reps <- grep("_r|_ir",samples,value=TRUE) # get the replicates (ending with _r or _ir)
samps <- match(sub("_r|_ir","",reps),samples) # match against its sample (ie names w/o _r or _ir)
不過我照著執行後samps只會出現一堆NA
想問這是怎麼回事?
--
Sent from my Windows
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.122.136.81
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1530089084.A.717.html
→ andrew43: 因為找不到相等者所以回傳NA。 06/27 18:15
→ piggood: 因為有用 sub 把 _r 或 _ir 刪除,所以 match 不到?! 06/28 11:20
原文上面寫的 我也覺得很奇怪
※ 編輯: k97231 (140.122.152.43), 07/02/2018 09:36:46
→ andrew43: 你想想如果samples中有任何"A"或"B"會如何? 07/08 03:17