为什么setdiff()无法识别元素

时间:2014-04-28 12:39:55

标签: r list set-difference

我有一张大表(图片)如下:

screenshot

然后我导入并提取了一些如下:

mytable<-read.table(file="annotation.txt", na.strings=c("", "NA"), header=F, sep="\t")
> str(mytable)
'data.frame':   1320 obs. of  933 variables:
 $ V3  : chr  "ACSS2" "IDH3B" "RPE" "UGT1A10" ...
 $ V4  : chr  "GCK" "DLST" "RPIA" "UGT1A8" ...
 $ V5  : chr  "PGK2" "PCK2" "PGM2" "RPE" ...
 $ V6  : chr  "PGK1" "CS" "PGLS" "UGT1A7" ...
 $ V7  : chr  "PDHB" "PDHB" "PRPS2" "UGT1A6" ...
 $ V8  : chr  "PDHA1" "PCK1" "FBP2" "UGT2B28" ...
 $ V9  : chr  "PDHA2" "PDHA1" "PFKM" "UGT1A5" ...
 $ V10 : chr  "PGM2" "LOC642502" "PFKL" "CRYL1" ...
 $ V11 : chr  "TPI1" "PDHA2" "TALDO1" "UGDH" ...
 $ V12 : chr  "ACSS1" "LOC283398" "TKT" "UGT2A1" ...
 $ V13 : chr  "FBP1" "FH" "FBP1" "GUSB" ...
 $ V14 : chr  "ADH1B" "SDHD" "TKTL2" "UGT1A9" ...
######up to:
 $ V97 : chr  NA NA NA NA ...
 $ V98 : chr  NA NA NA NA ...
 $ V99 : chr  NA NA NA NA ...
 $ V100: chr  NA NA NA NA ...
 $ V101: chr  NA NA NA NA ...

> example_table<-mytable[1:5, 1:5]

> example_table

                                                      V3     V4   V5     V6     V7
KEGG_GLYCOLYSIS_GLUCONEOGENESIS                 ACSS2    GCK PGK2   PGK1   PDHB
KEGG_CITRATE_CYCLE_TCA_CYCLE                    IDH3B   DLST PCK2     CS   PDHB
KEGG_PENTOSE_PHOSPHATE_PATHWAY                    RPE   RPIA PGM2   PGLS  PRPS2
KEGG_PENTOSE_AND_GLUCURONATE_INTERCONVERSIONS UGT1A10 UGT1A8  RPE UGT1A7 UGT1A6
KEGG_FRUCTOSE_AND_MANNOSE_METABOLISM              MPI   PMM2 PMM1   FBP2   PFKM

> dput(example_table)

structure(list(V3 = c("ACSS2", "IDH3B", "RPE", "UGT1A10", "MPI"
), V4 = c("GCK", "DLST", "RPIA", "UGT1A8", "PMM2"), V5 = c("PGK2", 
"PCK2", "PGM2", "RPE", "PMM1"), V6 = c("PGK1", "CS", "PGLS", 
"UGT1A7", "FBP2"), V7 = c("PDHB", "PDHB", "PRPS2", "UGT1A6", 
"PFKM")), .Names = c("V3", "V4", "V5", "V6", "V7"), row.names = c("KEGG_GLYCOLYSIS_GLUCONEOGENESIS", 
"KEGG_CITRATE_CYCLE_TCA_CYCLE", "KEGG_PENTOSE_PHOSPHATE_PATHWAY", 
"KEGG_PENTOSE_AND_GLUCURONATE_INTERCONVERSIONS", "KEGG_FRUCTOSE_AND_MANNOSE_METABOLISM"
), class = "data.frame")

我不明白发生了什么。然后,当我想用​​另一个列表文件对其进行setdiff时,它没有响应(因为有些是重复的):

> dput(example_SP)
list(c("MPI", "PMM1", "PFKM", "DKFZP434I0714", "TSPYL4", "ACSM3", 
"MET", "ADA"))

> setdiff(example_SP[[1]], example_table[5,])
[1] "MPI"           "PMM1"          "PFKM"          "DKFZP434I0714" "TSPYL4"        "ACSM3"        
[7] "MET"           "ADA"

如果有人能帮助我会很棒。此致

0 个答案:

没有答案