Error in rle(toplevel) : 'x' must be a vector of an atomic type

Dear Community,

I'm trying to do my first shiny app and when I try to publish I have the following error: "Error in rle(toplevel) : 'x' must be a vector of an atomic type".
It seems to be that the reactive Event in the server is not returning a vector and instead is returning a list. Does any of you know how can I fix it?
The code is:


library(ggplot2)
library(readxl)

function(input, output) {
    auto_parts <- read_excel("./Auto-parts-bien2.xlsx", col_types = c("text", "text", "text",  "numeric", "numeric", "numeric", "numeric", "numeric",  "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"))

    re <- eventReactive(input$update,{
        data <- data.frame(auto_parts)
        data <- data[(data$Market.Value..EUR. >= input$marketcap[[1]])&(data$Market.Value..EUR. <= input$marketcap[[2]]),]
        data <- data[(data$Price.to.Earnings >= input$per[[1]])&(data$Price.to.Earnings <= input$per[[2]]),]
        data <- data[(data$Price.to.Book >= input$pb[[1]])&(data$Price.to.Book <= input$pb[[2]]),]
        data <- data[(data$Price.Index.48.m >= input$growth[[1]])&(data$Price.Index.48.m <= input$growth[[2]]),]
        data <- data[(data$ROIC.5.yr.avg >= input$roic[[1]])&(data$ROIC.5.yr.avg <= input$roic[[2]]),]
        if(input$ebitda == "Positive"){
            data <- data[data$X5yr.Growth.EBITDA >= 0,]
        }else {
            data <- data[data$X5yr.Growth.EBITDA <= 0,]
        }
        if(input$country != "All"){
            data <- data[data$Country == input$country,]
        }
        drop <- c("Piotroski.F.Score","Price.Index.12.m","Price.Index.48.m","X5yr.Growth.EBITDA"
                  ,"ROIC.5.yr.avg","Price.to.Sales","Fcf.Yield.5.yr.avg")
        data_2 <- data[,!(names(data) %in% drop)]
        return(data_2)
    })
    # Filter data based on selections
    output$table <- DT::renderDataTable(DT::datatable({
         re()
    }))

}

After 5 days getting crazy with this. I've solved the issue. It was not related with the code, the path where the app was, had strange characters. Hope it helps for all of you

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.