小编phu*_*ion的帖子

基于查找向量的条件重新编码

我需要d根据查找向量有条件地重新编码我的数据帧。

dput(lookup)
structure(c("Apple", "Apple", "Banana", "Carrot"), .Names = c("101", "102", "102", "103"))
dput(d)
structure(list(pat = c(101, 101, 101, 102, 102, 103), gene = structure(1:6, .Label = c("a", 
"b", "c", "d", "e", "f"), class = "factor"), Apple = c(0.1, 0.2, 
0.3, 0.4, NA, NA), Banana = c(NA, NA, NA, NA, 0.55, NA), Carrot = c(NA, 
NA, NA, NA, NA, 0.6)), .Names = c("pat", "gene", "Apple", "Banana", 
"Carrot"), row.names = c(NA, -6L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)

d是我通过的一个宽数据框reshape。我需要重新编写任何NAs …

lookup r dplyr recode

5
推荐指数
1
解决办法
614
查看次数

标签 统计

dplyr ×1

lookup ×1

r ×1

recode ×1