I am trying to use the promotions and transactions data, and compute the total sales for all products that were on a display in the front of the store (display_location = 1) but I keep getting this error
Error in `auto_copy()`:
! `x` and `y` must share the same src.
ℹ set `copy` = TRUE (may be slow).
Backtrace:
1. ... %>% arrange(desc(total_sales))
5. dplyr:::inner_join.data.frame(., get_transactions, by = "product_id")
6. dplyr::auto_copy(x, y, copy = copy)
I tried the following:
get_promotions() %>%
filter(display_location == 1) %>%
inner_join(get_transactions, by = "product_id" ) %>%
summarize(total_sales = sum(sales_value)) %>%
arrange(desc(total_sales))
CodePudding user response:
You should add ()
to get_transactions
because it is a function. Here is some reproducible code:
library(completejourney)
library(dplyr)
get_promotions() %>%
filter(display_location == 1) %>%
inner_join(get_transactions(), by = "product_id" ) %>%
summarize(total_sales = sum(sales_value)) %>%
arrange(desc(total_sales))
#> # A tibble: 1 × 1
#> total_sales
#> <dbl>
#> 1 67430178.
Created on 2023-02-04 with reprex v2.0.2