首页 > 解决方案 > 无法运行我闪亮的应用程序 - readLines 中的错误(文件,警告 = FALSE):无法打开连接

问题描述

我正在尝试运行我自己的闪亮应用程序,但我总是在控制台中收到一条错误消息。这是警告消息:

Loading required package: shiny
Warning in base::file(file, encoding = enc) :
  'raw = FALSE' but '/Users/octaviodelsueldo/Documents/CUNEF/Tecnicas de Visualizacion/Trabajo_2_Shiny/app.R' is not a regular file
Warning in readLines(file, warn = FALSE) :
  cannot open file '/Users/octaviodelsueldo/Documents/CUNEF/Tecnicas de Visualizacion/Trabajo_2_Shiny/app.R': it is a directory
Error in readLines(file, warn = FALSE) : cannot open the connection

我不知道为什么会这样。如果其中任何一个不正确,我会在下面向您展示代码。

library(shiny)
library(ggplot2)
# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("Ejercicio 2 de Shiny"),

        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot", hover = "hover"), #el input hover se va a disparar cuando un usuario pase el raton en la grafica distplot. Su contenido es una lista de cosas.
           dataTableOutput("resultadoFiltro") #permite imprimir un dataframe de forma tabulada
        )
    
)

# Define server logic required to draw a histogram
server <- function(input, output) {
    
    # ReactiveVal es un reactivo que se puede modificar y hacer cosas como agregar o retirar lineas o columnas. 
    # ReactiveVal lo manipulamos nosotros directamente
    dataset <- reactiveVal({
        data.frame(x = rnorm(30), y = rnorm(30))
    })
    
    #Plot de la distribucion normal aleatoria creada
    output$distPlot <- renderPlot({
        ggplot(dataset(), aes(x = x, y = y)) + geom_point()
    })
    
    
    output$resultadoFiltro <- renderDataTable({
        nearPoints(dataset(), input$hover) #busca los puntos cercanos a una posicion. Esta funcion devuelve un dataframe con las filas seleccionadas
    })

}

# Run the application 
shinyApp(ui = ui, server = server)

任何帮助您将不胜感激。

标签: rshinyrstudio

解决方案


推荐阅读