【发布时间】:2019-06-16 11:49:50
【问题描述】:
我会用 diplyr 加入一些表格,但它提醒我一些错误。
我有两个变量,我想加入它们,但它提醒了我一些错误。怎么了?如何使用 dplyr 创建一个在行之间进行正确匹配的表?谢谢
Mouth_tissues= counts_sample_mouth0$counts
Glands= counts_sample_gland0$counts
head(Mouth_tissues)
Mouth_tissues
gene0 547
gene1 78
gene2 5
gene3 13
gene4 16
gene5 49
> head(Glands)
Glands
gene0 332
gene1 60
gene2 583
gene3 6964
gene4 2162
gene5 6
> full_join(Mouth_tissues, Glands)
Error in UseMethod("full_join") :
no applicable method for 'full_join' applied to an object of class "c('matrix', 'integer', 'numeric')"
然后我做了:
mouth<-as.data.frame.matrix(Mouth_tissues)
glands<-as.data.frame.matrix(Glands)
library(dplyr)
full_join(mouth, glands)
Error: `by` required, because the data sources have no common variables
Call `rlang::last_error()` to see a backtrace
dput(head(counts_sample_gland0))
dput(head(counts_sample_mouth0))
【问题讨论】:
-
两个对象都需要是数据框,
full_join才能工作。如果Mouth_tissues的class()和Glands不是data.frame,则连接将不起作用。 -
好的。谢谢。如何将它们转换为数据框?
-
您能否将
dput(head(counts_sample_gland0))和dput(head(counts_sample_mouth0))的输出添加到您的问题中? -
好的!我做到了……
-
不,我的意思是这两行的 输出 如果你将它们粘贴到你的 R shell 中。 R 输出将类似于
structure(list(...