Error that's related to working directory when using plotly in R

Viewed 64

Im trying to use the ggplotly function on a certain plot, and i get a strange error that's related to the working directory.

here is a reproducible example:

library(dplyr)
library(tidyr)
library(ggplot2)
library(plotly)

#constructing a data frame
data = data.frame(date = seq.Date(as.Date("2021-08-21"),as.Date("2021-08-30"), "day"),
                 first = rnorm(1:10),
                 second = rnorm(1:10),
                 third = rnorm(1:10)) 
data
#turning the data to long format
data_long <- data %>% 
  gather(key = "index", value = "value", -date)

#graphing
plot <- data_long %>% 
  ggplot(aes(x=date, y=value, color=index))+
  labs(x="", y="value")+
  geom_line()+
  facet_wrap(~index)
plot

ggplotly(plot)

Everything is running well except for the ggplotly command. When i run it i get the following error:

Error in setwd(dir) : cannot change working directory

I don't understand the connection between the command and the error message, since i haven't mean to change the directory at all.

Thank you very much

0 Answers
Related