【发布时间】:2020-01-12 06:36:00
【问题描述】:
我正在使用闪亮,因为我想做一个仪表板,但是当我做一个情节时出现了一些错误。我想从我自己电脑中的文件中读取数据库。
我不想要这个https://jamesmccammon.com/2014/12/29/shiny-web-app/
#ui
library(shinydashboard)
sidebar <- dashboardSidebar(
hr(),
sidebarMenu(id="tabs",
menuItem("a", tabName="a", icon=icon("pagelines"), selected=TRUE),
menuItem("b", icon=icon("chart-bar"),
menuItem("c", tabName = "c", icon=icon("chart-bar")),
menuItem("d", tabName = "d", icon = icon("chart-bar")),
menuItem("e", tabName = "e", icon=icon("mortar-board")),
menuItem("f", tabName = "f", icon = icon("question"))
),width = 285
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "a",
withMathJax(),
includeMarkdown("principal.Rmd")
),
tabItem(tabName = b",
dateRangeInput('b_fecha',
label = 'Por favor seleccionar fecha:',
start = Sys.Date() - 2, end = Sys.Date() + 2, format = "mm yyyy", startview = 'year', language = 'es'
),
column(width = 8,
box( width = NULL, plotOutput(outputId = "b_iden_grap"), collapsible = TRUE,
title = "Plot", status = "primary", solidHeader = TRUE)
)
)
))
dashboardPage(
dashboardHeader(title = "title", titleWidth=285),
sidebar,
body
)
# server
library(shinydashboard)
library(shiny)
library(readxl)
library(zoo)
shinyServer(function(input, output) {
df1.1.1=data.frame(read_excel("C:/Users/.../Base.xlsx", sheet = "1.1.1"))
df1.1.1$mes.y.año = as.yearmon(as.Date(df1.1.1$mes.y.año, origin="1899-12-30"))
output$admision_iden_grap <- renderPlot({
plot(df1.1.1$mes.y.año, (1-(df1.1.1$errores/df1.1.1$egresos))*100, ylim= c(0,100), type ="h")
})
})```
shiny::runApp('C:/.../...') 正在加载所需的包:闪亮 收听http://###.#.#.#:#### 附件包:‘shinydashboard’ 以下对象被“package:graphics”屏蔽: 盒子 checkEncoding(file) 中的警告: 输入文件 C:...\Prueba/server.R 似乎没有在 readLines(file, warn = FALSE) 中以 UTF8 警告编码: 在输入连接 'C:.../server.R' 上发现无效输入 解析错误(文件,keep.source = FALSE,srcfile = src,编码 = enc): C:.../server.R:11:0: 输入意外结束 9: df1.1.1=data.frame(read_excel("C:/Users/.../Base.xlsx", sheet = "1.1.1")) 10: df1.1.1$mes.y.a ^ 警告:sourceUTF8 中的错误:错误采购 C:...\AppData\Local\Temp\RtmpwbMkRB\file42c486c4a65 [没有可用的堆栈跟踪] sourceUTF8 中的错误(serverR,envir = new.env(parent = globalenv())):错误采购 C:...\AppData\Local\Temp\RtmpwbMkRB\file42c486c4a65
【问题讨论】:
-
看起来您的特殊字符会导致问题(“n”与波浪号)。我会尝试将文件保存为 UTF8 编码(在 RStudio 中:文件 -> 使用编码保存),或者删除这些特殊字符。
-
您可能在
tabName = b"中缺少" -
@Stéphane-Laurent 你是对的!就是这样,谢谢!
-
好的,所以我转换为答案。
-
@JRN,如果我的回答解决了你的问题,那么请考虑accepting the answer。否则,该问题将被网站视为未回答。
标签: r shiny shinydashboard shinyapps