繁体   English   中英

合并R中的数据帧

[英]Merging dataframes in R

我有两个数据帧,我想基于一个公共列进行合并

 [dataset A][http://public.justcloud.com/dldzm0fnsp.4540049] 

 [dataset B][http://public.justcloud.com/dldzmx1758.4540049]

运用

    merged terms <- dd_B[dd_B$GOBPID %in% dd_A$GOBPID,]

给我以下错误

    <0 rows> (or 0-length row.names)

我已经尝试使用合并,这给了我同样的错误。

你在这些文件上使用了read.csv 但是,如果您在一个体面的文本编辑器中打开文件,您会看到这些文件实际上是制表符分隔的文件,因此更适合的工具是read.delim

这是我做的:

df1 <- read.delim("~/Downloads/dd_a.csv", strip.white = TRUE)
df2 <- read.delim("~/Downloads/dd_B.csv", strip.white = TRUE)
out <- merge(df2, df1)

head(out)
#       GOBPID Pvalue OddsRatio ExpCount Count Size                                         Term
# 1 GO:0000038  0.036     7.008        0     2   49 very long-chain fatty acid metabolic process
# 2 GO:0006412  0.013     2.704        3     8  510                                  translation
# 3 GO:0006413  0.001    11.556        0     4   62                     translational initiation
# 4 GO:0006414  0.022     9.417        0     2   37                     translational elongation
# 5 GO:0006448  0.036    32.723        0     1    6       regulation of translational elongation
# 6 GO:0006457  0.041     2.753        2     5  308                              protein folding

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM