DiegoUsaiUK/Market_Basket_Analysis

Converting a Binary rating matrix to dgCMatrix Class

Closed this issue · 1 comments

@DiegoUsaiUK I ran into an error with dgCMatrix while running part 3 of the Market Basket Analysis Code, what do you suggest ? I have tried to different things but I couldn't figure it out
Here is the code and the error message is below:
new_order <- item_list %>%
mutate(value = as.numeric(Description %in% customer_order)) %>%
spread(key = Description, value = value) %>%
as.matrix() %>%
as("dgCMatrix")
Error in item_list %>% mutate(value = as.numeric(Description %in% customer_order)) %>% :
could not find function "%>%"

Hi, thanks for reaching out.

The error message you get tells me that R is not finding the "%>%" operator (aka 'the forward pipe').
First, I'd suggest to restart your R session and make sure that the 'dplyr' and 'tidyr' libraries (or the 'tidyverse', which contains both) are loaded. These are the libraries that use the "%>%" operator.

Second, make sure that there are no backspaces after the "%>%". Sometimes when R finds a space it expects something ON THE SAME LINE and gets stuck there when it should instead check the following line