繁体   English   中英

如何阅读闪亮的 xls? 工作室

[英]How can I read a xls in shiny? R-Studio

我正在使用闪亮的,因为我想做一个仪表板,但是当我做一个绘图时会出现一些错误。 我想从我自己电脑中的文件中读取数据库。

我不想要这个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:/.../...') 正在加载所需的包:shiny 正在监听http://###.#.#.#:####附加包:'shinydashboard'以下对象从 'package:graphics' 中被屏蔽: checkEncoding(file) 中的框警告:输入文件 C:...\\Prueba/server.R 似乎没有以 UTF8 编码 readLines(file, warn = FALSE) 中的警告) : 在输入连接 '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.ya ^ 警告:sourceUTF8 中的错误:错误来源 C:...\\AppData\\Local\\Temp\\RtmpwbMkRB\\file42c486c4a65 [没有可用的堆栈跟踪] sourceUTF8 中的错误(serverR,envir = new.env(parent = globalenv()) )) :错误采购 C:...\\AppData\\Local\\Temp\\RtmpwbMkRB\\file42c486c4a65

问题是由于像ñ这样的特殊字符。

正如您在警告消息中看到的:

输入文件 C:...\\Prueba/server.R 似乎没有以 UTF8 编码

因此,请以 UTF8 编码保存您的文件。 要在 RStudio 中执行此操作,请执行File -> Save with encoding (如果仍然不起作用,请删除特殊字符)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM