不完全确定你有什么样的数据结构。这里有一个快速的解决方案,希望对您有所帮助在找什么:
splitFn <- function(x) expand.grid(df[x,"a"] %>% as.character %>% strsplit(., ",") %>% unlist, df[x, "b"])
ldply(1:nrow(df), splitFn)
Var1 Var2
1 SLC6A8 Cerebral creatine deficiency syndrome 1, 300352(3)
2 CRTR Cerebral creatine deficiency syndrome 1, 300352(3)
3 CCDS1 Cerebral creatine deficiency syndrome 1, 300352(3)
4 BCAP31 Deafness, dystonia, and cerebral hypomyelination
5 BAP31 Deafness, dystonia, and cerebral hypomyelination
6 DXS1357E Deafness, dystonia, and cerebral hypomyelination
7 DDCH Deafness, dystonia, and cerebral hypomyelination
8 ABCD1 Adrenoleukodystrophy, 300100(3), X-linked recessive
9 ALD Adrenoleukodystrophy, 300100(3), X-linked recessive
10 AMN Adrenoleukodystrophy, 300100(3), X-linked recessive
11 PLXNB3 <NA>
12 PLXN6 <NA>
我会用
df <- structure(list(a = structure(c(4L, 2L, 1L, 3L), .Label = c("ABCD1,ALD,AMN",
"BCAP31,BAP31,DXS1357E,DDCH", "PLXNB3,PLXN6", "SLC6A8,CRTR,CCDS1"
), class = "factor"), b = structure(c(1L, 3L, 2L, NA), .Label = c(" Cerebral
creatine deficiency syndrome 1, 300352(3)",
"Adrenoleukodystrophy, 300100(3), X-linked recessive", "Deafness, dystonia, and cerebral hypomyelination"
), class = "factor")), .Names = c("a", "b"), row.names = c(NA,
-4L), class = "data.frame")```
*“?难道这在R上做” *的data.frame - 最有可能的,但你到目前为止尝试过什么?这不是一个代码写入服务。 – nrussell
我一直在使用R的几件事情,但在这种情况下,我不知道我到底需要看什么。我只想提示,不一定是代码! – VasoGene