使用dplyr在Rstudio中的左连接遇到麻烦

时间:2019-02-13 23:27:49

标签: r

Imgur Link

错误消息:

  

错误:by不能包含LHS缺少的连接列id   致电rlang::last_error()查看回溯

我尝试了很多变体,但是似乎我无法让Rstudio认识到“ id”是两个单独表中的一列,不确定应该怎么做。

输入代码:

## View the names of the tables in the database
tables <- dbListTables(mydb)
tables

## View the columns in each of the tables that we have and store each as a dataframe
orders <- data.frame(dbListFields(mydb, 'orders'))
product_sales <- data.frame(dbListFields(mydb, 'product_sales'))
orders
product_sales

library(tidyverse)
# perform a left join to create one table
left_join(orders, product_sales, by = "id")

0 个答案:

没有答案