r - dplyr 和完全加入选项的一些问题
问题描述
我会用 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))
解决方案
我想这就是你想要做的?
已使用“Num”列上的完全连接来连接两个表。
library(tidyverse)
MouthTissue=c("gene0","gene1")
Num=c(547,78)
Mouthtissues_df=data.frame(MouthTissue,Num)
Glands=c("gene0","gene1")
Num=c(332,60)
Glands_df=data.frame(Glands,Num)
fulljoin=dplyr::full_join(Glands_df,Mouthtissues_df)
推荐阅读
- php - 在 php 中使用 $_SERVER['HTTP_REFERER'] 登录后无法重定向
- python - 如何在 Python 中更新 GUI 窗口?
- c# - 如何用零替换三位数字
- javascript - js中如何接收键值类型函数的函数参数?
- html - 即使多次更改位置,侧边栏也没有延伸到整个页面?
- android-studio - Flutter:在 null 上调用了更新
- c# - AudioFileInputNode 播放完成后自定义音频效果如何产生一些声音
- c# - 使用 JToken 更新 JObject
- python - 如何使用 django-meta 模块(或任何更简单的方法)来呈现 html 元标记
- javascript - 使用 toLocaleString 时出现意外结果