【发布时间】:2015-11-29 17:34:58
【问题描述】:
我有一个 Plotly 帐户和一个 R 脚本,它创建了一个我想在我的 Plotly 页面上发布的情节。在查看了 Plotly 入门页面和其他一些在线建议后,我最终得到了这段代码。
library(XLConnect)
library(dplyr)
library(ggplot2)
library(devtools)
library(plotly)
##Preparing the data file
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)
但是,当我执行代码时会出现此错误:
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")
我该如何解决这个问题并发布我的图?我还尝试了以下方法:
ggplotly(plot_region)
但它会出现此错误:
Error in `[[<-.data.frame`(`*tmp*`, a, value = c("ΣΤΕΡΕΑ ΕΛΛΑΔΑ", :
replacement has 483 rows, data has 13
【问题讨论】: