0

I am using R with Anaconda and Jupyter. Also I am using tidyverse library.

When I run:

days_label <- factor(df$days)

fct_recode(days_label,
                  'Mon;Tue;Wed;Thu;Fri;' = 1,
                  'Sat;' = 2,
                  'Sun;' = 3) 

I get an error saying that R can't find fct_recode function. I have tried with ?tidyverse and I get the full description of this function.

Is it a problem regarding R's installation, or there is something wrong with my code?

Simone
  • 4,800
  • 12
  • 30
  • 46
  • you need to load `library(forcats)` – Zafar Oct 14 '17 at 01:43
  • @Dan I have tried to load `forcats`, but I get the same error. – Simone Oct 14 '17 at 09:01
  • forcats does not get loaded when you load tidyverse, you have to load it explicitly as I have shown above. install.packages(“tidyverse”) will install a bunch of packages that do not get loaded when you load tidyverse. Hope this helps. – Zafar Oct 15 '17 at 13:35

1 Answers1

0

try forcats::fct_recode()

Although not sure you code work as is, see ?forcats::fct_recode() for examples:

fct_recode(x, fruit = "apple", fruit = "banana")
BigTimeStats
  • 447
  • 3
  • 12