我有一个文件:
FILE_A:
ID C1.x C2.x C3.x C4.x C5.x
M1 60 32 19 25 5
M2 5 14 12 15 5
M3 51 2 2 8 8
M4 15 8 8 8 7
M5 12 86 7 8 9
FILE_B:
ID C1.y C2.y C3.y C4.y C5.y
M1 N K K K N
M2 M M M M M
M3 Y T T T T
M4 A A A A A
M5 C C N C C
如果小于5,则过滤器为5.然后相应的列应为N.
由于
答案 0 :(得分:1)
如果一切正常,您只需使用:
#Test data
dat <- data.frame("ID"=c("M1","M2", "M3", "M4", "M5"), "C1.x"=c(60,5,51,15,12), "C2.x"=c(32,14,2,8,86), "C3.x"=c(19,12,2,8,7), stringsAsFactors=FALSE)
dat2 <- data.frame("ID"=c("M1","M2", "M3", "M4", "M5"), "C1.x"=c("N", "M", "Y", "A", "C"), "C2.x"=c("N", "M", "Y", "A", "C"), "C3.x"=c("N", "M", "Y", "A", "C"), stringsAsFactors=FALSE)
dat2[dat < 5] <- "N"
我认为这是您正在寻找的输出。如果没有,请澄清。