我无法使用r在我的shinyapp中渲染高图。我正在努力使其成功。但该小组只是显示除了图表之外的标题和信用。谁能请帮忙。这是我的代码:
library(dplyr)
library(ggplot2)
library(highcharter)
library(maps)
library(scales)
library(DT)
require(ggthemes)
d <- read.csv(file = "cities_r2.csv")
df <-separate(data = d, col = location, into = c("lat","lng"),sep = ",")
df$name_of_city <- trimws(df$name_of_city)
ui <- fluidPage(
h1("Top 500 Indian Cities"),
mainPanel(highchartOutput(outputId = "plot1", height = "800px"))
)
server <- function(input, output, session) {
output$plot1 <- renderHighchart({
ds <- df %>%
group_by(state_name) %>%
summarise(total = sum(population_total)) %>%
arrange(desc(total))
sx<-ds$state_name
sy<-ds$total
hchart(ds, x = sx, y = sy, type = "column", color = sx) %>%
hc_title(text = "States by number of cities in Top 500") %>%
hc_add_theme(hc_theme_google())
hchart(ds, x = sx, value = sy, color = sy, type = "treemap") %>% hc_add_theme(hc_theme_google()) %>%
hc_credits(enabled = TRUE, text = "Sources: Census India 2011", style = list(fontSize = "10px")) %>%
hc_title(text = "States by Number of Cities in Top 500")
})
}
shinyApp(server = server, ui = ui)
Here is how my app looks like at present
这是我的会话信息
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 LC_MONETARY=English_India.1252
[4] LC_NUMERIC=C LC_TIME=English_India.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] magrittr_1.5 rCharts_0.4.5 devtools_1.12.0 ggthemes_3.3.0 leaflet_1.0.1 tidyr_0.6.1
[7] DT_0.2 scales_0.4.1 maps_3.1.1 ggplot2_2.2.1 dplyr_0.5.0 shiny_1.0.0.9000
[13] highcharter_0.5.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.9 git2r_0.18.0 plyr_1.8.4 tools_3.3.2 xts_0.9-7
[6] digest_0.6.11 memoise_1.0.0 lubridate_1.6.0 jsonlite_1.2 tibble_1.2
[11] nlme_3.1-129 gtable_0.2.0 lattice_0.20-34 psych_1.6.12 igraph_1.0.1
[16] DBI_0.5-1 curl_2.3 yaml_2.1.14 parallel_3.3.2 httr_1.2.1
[21] withr_1.0.2 stringr_1.1.0 htmlwidgets_0.8 grid_3.3.2 data.table_1.10.0
[26] R6_2.2.0 foreign_0.8-67 RJSONIO_1.3-0 whisker_0.3-2 reshape2_1.4.2
[31] purrr_0.2.2 TTR_0.23-1 htmltools_0.3.5 rlist_0.4.6.1 rsconnect_0.7
[36] assertthat_0.1 quantmod_0.4-7 mnormt_1.5-5 colorspace_1.3-2 mime_0.5
[41] xtable_1.8-2 httpuv_1.3.3 stringi_1.1.2 lazyeval_0.2.0.9000 munsell_0.4.3
[46] broom_0.4.1 zoo_1.7-14