I have a Plotly account and an R script that creates a plot that I want to publish on my Plotly page. After looking at the Plotly Getting Started page and some other online tips, I ended up with this code.
library(XLConnect)
library(dplyr)
library(ggplot2)
library(devtools)
library(plotly)
myurl <- "http://minagric.gr/images/stories/docs/agrotis/Elia/egekrimenes_typop_monades220715.xls"
temp <- file.path(getwd(), "temp.xls")
download.file(myurl,temp)
mydata <- readWorksheetFromFile(temp, sheet=1, header = TRUE, startRow = 2)
colnames(mydata)<-c("name", "approval_code", "region", "prefecture")
plot_region <- ggplot(mydata,aes(x=region)) +
geom_histogram(fill="lightblue") +
theme(plot.title = element_text(size=15, face="bold", vjust=2), axis.text.x=element_text(angle=50, size=5, vjust=0.35)) +
labs(title = "Olive oil plants per Region") +
xlab("Region") + ylab("Number of plants")
py <- plotly(username = "myusername", key = "mykey")
response<-py$ggplotly(plot_region)
However, this error occurs when executing the code:
Error in eval(expr, envir, enclos) : attempt to apply non-function
In addition: Warning messages:
1: 'plotly' is deprecated.
Use 'ggplotly' instead.
See help("Deprecated")
2: 'plotly' is deprecated.
Use 'plot_ly' instead.
See help("Deprecated")
How can I solve this problem and publish my stories? I also tried the following:
ggplotly(plot_region)
but he presents this error:
Error in `[[<-.data.frame`(`*tmp*`, a, value = c("ΣΤΕΡΕΑ ΕΛΛΑΔΑ", :
replacement has 483 rows, data has 13
source
share