在github上部署flexdashboard 问题背景
我正在尝试将flexdashboard部署到github,以便与其他人共享链接。我已经尝试过,但当我使用在github上部署flexdashboard 问题背景,r,github,shiny,flexdashboard,R,Github,Shiny,Flexdashboard,我正在尝试将flexdashboard部署到github,以便与其他人共享链接。我已经尝试过,但当我使用rmarkdown::render()或rmarkdown::render\u site()时,控制台中出现以下错误: Error: path for html_dependency not provided 当我尝试时,控制台显示创建的输出:C:/Users/danie/AppData/Local/Temp/Rtmpum47SE/file1604424c59ee.html,并且.html文
rmarkdown::render()
或rmarkdown::render\u site()
时,控制台中出现以下错误:
Error: path for html_dependency not provided
当我尝试时,控制台显示创建的输出:C:/Users/danie/AppData/Local/Temp/Rtmpum47SE/file1604424c59ee.html
,并且.html
文件不在“docs”文件夹中
代码
我有两个脚本:.yml
和.Rmd
;数据在工作目录中
yml先生
.Rmd
---
标题:“杀人案(1993-2019)”
输出:
flexdashboard::flex_仪表板:
方向:行
垂直布局:填充
主题:引导
#社交:菜单
运行时间:闪亮
---
```{r设置,include=FALSE}
库(flexdashboard)
图书馆(readxl)
图书馆(tidyr)
图书馆(dplyr)
图书馆(lubridate)
图书馆(GG2)
图书馆(绘本)
图书馆(比例尺)
图书馆(闪亮)
#职能####
阅读所有表格69和数据$EDAD<80,“70 a 79 años”,
ifelse(数据$EDAD>79和数据$EDAD<90,“80 a 89 años”,
ifelse(数据$EDAD>89和数据$EDAD<100,“90 a 99 años”,
ifelse(数据$EDAD>99,“100 años en adelante”,“sin grupo”()()()()()()()
返回(数据)
}
如上所述,由于您使用的是Shiny,您可以在internet上托管自己的Shiny服务器,也可以免费部署和托管您的Shiny应用程序,只要它不会获得大量流量。Rstudio使其很容易发布。然后,您可以创建一个github页面,并将其重定向到您的闪亮应用程序,同时还可以在github上备份代码
如上所述,由于您使用的是Shiny,您可以在internet上托管自己的Shiny服务器,也可以使用免费部署和托管您的Shiny应用程序,只要它不会获得大量流量。Rstudio使其很容易发布。然后,您可以创建一个github页面,并将其重定向到您的闪亮应用程序,同时还可以在github上备份代码
我认为问题在于您使用的是runtime:shinny
,它需要一个R进程来支持它,我想您在github页面上没有这个进程。另外,您的第二个链接指出RMD+shinny不适用于github页面。我认为问题在于您使用的是runtime:shinny
,它需要一个R进程来支持它,而我猜您在github页面上没有。另外,您的第二个链接指出RMD+shinny不适用于github页面。
name: "dashboardEco"
output_file: "docs"
---
title: "Homicidios (1993-2019)"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
theme: bootstrap
#social: menu
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(readxl)
library(tidyr)
library(dplyr)
library(lubridate)
library(ggplot2)
library(plotly)
library(scales)
library(shiny)
#funciones####
read_excel_allsheets <- function(filename, tibble = FALSE) {
# I prefer straight data.frames
# but if you like tidyverse tibbles (the default with read_excel)
# then just pass tibble = TRUE
sheets <- readxl::excel_sheets(filename)
x <- lapply(sheets, function(X) readxl::read_excel(filename, sheet = X))
if(!tibble) x <- lapply(x, as.data.frame)
names(x) <- sheets
x
} #leer todos los sheets de un excell y guarfarlos en una lista
gr_edad<-function(data){
data$g_edad<-ifelse(data$EDAD < 10, "0 a 9 años",
ifelse(data$EDAD > 9 & data$EDAD < 20, "10 a 19 años",
ifelse(data$EDAD > 19 & data$EDAD < 30, "20 a 29 años",
ifelse(data$EDAD > 29 & data$EDAD < 40, "30 a 39 años",
ifelse(data$EDAD > 39 & data$EDAD < 50, "40 a 49 años",
ifelse(data$EDAD > 49 & data$EDAD < 60, "50 a 59 años",
ifelse(data$EDAD > 59 & data$EDAD < 70, "60 a 69 años",
ifelse(data$EDAD > 69 & data$EDAD < 80, "70 a 79 años",
ifelse(data$EDAD > 79 & data$EDAD < 90, "80 a 89 años",
ifelse(data$EDAD > 89 & data$EDAD < 100, "90 a 99 años",
ifelse(data$EDAD > 99, "100 años en adelante","sin grupo")))))))))))
return(data)
}
sum_byage_c<-function(data){
df<-data.frame()
edades<-unique(data$g_edad)
for (edad in edades){
data_<-subset(data,data$g_edad == edad)
data_<-data_%>%group_by(fechao,categoria_movil) %>% summarise(Freq=n())
data_$g_edad<-edad
df<-rbind(df,data_)
}
return(df)
}
sum_byage_sc<-function(data){
df<-data.frame()
for (edad in unique(data$g_edad)){
data_<-subset(data,data$g_edad == edad)
data_<-data_%>%group_by(fechao,subcategoria_movil) %>% summarise(Freq=n())
data_$g_edad<-edad
df<-rbind(df,data_)
}
return(df)
}
comunas_tipoV<-function(data){
df<-data.frame()
comunas<-unique(data$com)
for (comuna in comunas){
data_<-subset(data,data$com == comuna)
data_<-data_%>%group_by(fechao,tipo_violencia) %>% summarise(Freq=n())
data_$com<-comuna
df<-rbind(df,data_)
}
return(df)
}
#procesamiento####
homicidios<-read_excel_allsheets("DATOS_1993-2019.xlsx")
homicidios<-homicidios[[2]]
homicidios$EDAD[is.na(homicidios$EDAD)]<-200
homicidios<-gr_edad(homicidios)
```
Column {.sidebar}
=======================================================================
###
```{r}
selectInput(inputId = "Edad_",
label = "Edad",
choices = unique(homicidios$g_edad))
#choices = genero,
#selected = "Total")
selectInput(inputId = "Mov_",
label = "Movil",
choices = unique(homicidios$categoria_movil))
#selected = "1993")
selectInput(inputId = "sMov_",
label = "sMovil",
choices = unique(homicidios$subcategoria_movil))
#selected = "1993")
selectInput(inputId = "Com_",
label = "Com",
choices = unique(homicidios$com))
#selected = "1993")
selectInput(inputId = "tipo_",
label = "Tipo",
choices = unique(homicidios$tipo_violencia))
#selected = "1993")
```
-----------------------------------------------------------------------
Categoría móvil, grupos de edad
=======================================================================
row {data-width=350}
-----------------------------------------------------------------------
### Móvil
```{r}
movil_<-homicidios[,c(8,11,16,18)]
movil_m<-subset(movil_,movil_$SEXO == "M")
movil_f<-subset(movil_,movil_$SEXO == "F")
#
movil_m<-sum_byage_c(movil_m)
movil_m$SEXO<-"M"
#
movil_f<-sum_byage_c(movil_f)
movil_f$SEXO<-"F"
#
#
#
movil<-rbind(movil_f,movil_m)
#
movil_r <- reactive({
movil[movil$g_edad == input$Edad_ & movil$categoria_movil == input$Mov_, c(1,3,5)]
})
#
#
renderPlotly({
movil <- movil_r()
cmov<-ggplot(data=movil, aes(fill=SEXO,x=fechao, y=Freq)) +
geom_bar(position="dodge",stat="identity")+
xlab("")+
ylab("")+
theme_classic()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5)) +
scale_x_continuous("Año",labels=as.character(movil$fechao),breaks = movil$fechao)
ggplotly(cmov)
})
```
row {data-width=350}
-----------------------------------------------------------------------
### Sub-móvil
```{r}
smovil_<-homicidios[,c(8,11,17,18)]
smovil_m<-subset(smovil_,smovil_$SEXO == "M")
smovil_f<-subset(smovil_,smovil_$SEXO == "F")
#
smovil_m<-sum_byage_sc(smovil_m)
smovil_m$SEXO<-"M"
#
smovil_f<-sum_byage_sc(smovil_f)
smovil_f$SEXO<-"F"
#
#
#
smovil<-rbind(smovil_f,smovil_m)
#
smovil_r <- reactive({
smovil[smovil$g_edad == input$Edad_ & smovil$subcategoria_movil == input$sMov_, c(1,3,5)]
})
#
#
renderPlotly({
smovil <- smovil_r()
smov<-ggplot(data=smovil, aes(fill=SEXO,x=fechao, y=Freq)) +
geom_bar(position="dodge",stat="identity")+
xlab("")+
ylab("")+
theme_classic()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5)) +
scale_x_continuous("Año",labels=as.character(smovil$fechao),breaks = smovil$fechao)
ggplotly(smov)
})
```
-----------------------------------------------------------------------
Tipo violencia, comunas
=======================================================================
row {data-width=350}
-----------------------------------------------------------------------
### Distribución Comunas - Tipo violencia
```{r}
#
homicidios$com[homicidios$com > 22]<-23
tipo_<-homicidios%>%group_by(com,tipo_violencia) %>% summarise(Freq=n())
#
#tipo_r <- reactive({
# tipo_[tipo_$com == input$Com_, c(1:3)]
# })
#
#
renderPlotly({
#tipo <- tipo_r()
tipov<-ggplot(data=tipo_, aes(fill=tipo_violencia,x=com, y=Freq)) +
geom_bar(position="stack",stat="identity")+
xlab("")+
ylab("")+
theme_classic()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5))+
scale_x_continuous("Comuna",labels=as.character(tipo_$com),breaks = tipo_$com)
ggplotly(tipov)
})
```
row {data-width=350}
-----------------------------------------------------------------------
### Tipo violencia por comuna
```{r}
#
tipo_<-comunas_tipoV(homicidios)
#
tipo_r <- reactive({
tipo_[tipo_$com == input$Com_, c(1:3)]
})
#
#
renderPlotly({
tipo <- tipo_r()
tipov<-ggplot(data=tipo, aes(fill=tipo_violencia,x=fechao, y=Freq)) +
geom_bar(position="stack",stat="identity")+
xlab("")+
ylab("")+
theme_classic()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5)) +
scale_x_continuous("Año",labels=as.character(tipo$fechao),breaks = tipo$fechao)
ggplotly(tipov)
})
```