我是相对较新的R,非常新的闪亮,但我一直未能找到有关这一错误的信息。
我创建了两个图,一个使用d3heatmap,另一个使用leaflet。当我单独运行脚本时,它们都能工作。我按照指示,使用boostrapPage()将两个图表显示在一起,显示得闪闪发亮。
代码可以在这里找到:https://github.com/jotasolano/dengueCR,但我还是会粘贴到下面。我得到了错误信息
ERROR: path[1]="": No such file or directory
在弹出窗口上显示图表(而不是在控制台上)。对为什么会发生这种事有什么想法吗?
服务器。R:
library(dplyr)
library(d3heatmap)
library(RColorBrewer)
library(shiny)
library(leaflet)
library(rCharts)
function(input, output, session) {
output$heatmap <- renderD3heatmap({
#convert to df and drop total
cases <- read.csv("casos_2015.csv") %>%
select(-Total) %>%
select(-Semana)
d3heatmap(cases, scale = "row",
dendrogram = "none",
color = scales::col_quantile("Reds", NULL, 10),
xaxis_font_size = "10px",
show_grid = 0.2)
})
output$geomap <- renderPlot({
data <- read.csv("cantones.csv")
casos_popup <- paste0("<strong>Canton: </strong>", data$canton,
"<br><strong>Cases: </strong>", data$casos,
"<br><strong>Rate: </strong>", signif(data$tasa, 3))
m <- leaflet(data) %>%
addProviderTiles("CartoDB.Positron") %>%
addCircles(~lng,
~lat,
popup = casos_popup,
radius = ~sqrt(casos) * 300,
weight = 1,
color = "red")
})
}ui.R:
library(shiny)
library(d3heatmap)
library(leaflet)
library(rCharts)
bootstrapPage(mainPanel(width = 12,
div(class = "row",
div(showOutput("heatmap", "d3heatmap"), class = "span6"),
div(showOutput("geomap", "leaflet"), class = "span6")
)
))此外,如果你看到任何可怕的做法,请随时注意,因为就像我说的,我是相对较新的,文档有时是混乱的。
谢谢!
发布于 2016-02-20 05:17:31
我想你在使用一些过时的函数。传单和d3heatmap都有自己的基于have工具的呈现/输出功能。将您的UI更改为
bootstrapPage(mainPanel(width = 12,
div(class = "row",
div(d3heatmapOutput("heatmap"), class = "span6"),
div(leafletOutput("geomap"), class = "span6")
)
))我还会将数据处理置于响应之外,因为它不会改变,要么放在服务器中,要么放在启动时读取的global.R中。
使用这些小的mods,您的服务器可能是
library(dplyr)
library(d3heatmap)
library(RColorBrewer)
library(shiny)
library(leaflet)
library(rCharts)
cases <- read.csv("casos_2015.csv") %>%
select(-Total) %>%
select(-Semana)
## I would add the labels here as well unless those are subject to change
data <- read.csv("cantones.csv")
function(input, output, session) {
output$heatmap <- renderD3heatmap({
d3heatmap(cases, scale = "row",
dendrogram = "none",
color = scales::col_quantile("Reds", NULL, 10),
xaxis_font_size = "10px",
show_grid = 0.2)
})
output$geomap <- renderLeaflet({
casos_popup <- paste0("<strong>Canton: </strong>", data$canton,
"<br><strong>Cases: </strong>", data$casos,
"<br><strong>Rate: </strong>", signif(data$tasa, 3))
m <- leaflet(data) %>%
addProviderTiles("CartoDB.Positron") %>%
addCircles(~lng,
~lat,
popup = casos_popup,
radius = ~sqrt(casos) * 300,
weight = 1,
color = "red")
m
})
}https://stackoverflow.com/questions/35517622
复制相似问题