'R: Failing to knit on a pivot longer, despite the function working when run by itself
Kia Ora,
I am running into an issue where I have a pivot_longer() than works when I run the code and the output works and is correct. However, when I try to knitt to html I get the following error message:
Error in -`x type` : invalid argument to unary operator Calls: <Anonymous> ... lapply -> FUN -> reorder -> reorder.default -> tapply Execution halted
This is an example of the offending code:
longer_df <- df %>%
pivot_longer(c(contains("common_phrase")),
names_to = "x type",
values_to = "x quantity")
Does anyone have an idea why the code works, but fails to knitt?
Solution 1:[1]
It appears I fixed the issue by adding 'na.rm = TRUE' to my ggplot calls. Weird given that the errors were not attributed to a ggplot call.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Paru at R |
