2

I'm developing a R Studio Shiny app, the logic consist in load two excel files into dataframes and using fuzzyjoin package to make a inner join between these dataframes, below is the code of my shiny.r and server,r, loading of excel files are correctly but when I get into Conciliacion tab I'm receiving the error

Error in : Column col must be a 1d atomic vector or a list:

ui.R:

library(shiny)
shinyUI(
fluidPage(
  titlePanel("Conciliación de reportes"),
    fixedRow(
     column(12,
      sidebarPanel(
      h4("Seleccione el primer reporte:"),              
      fileInput('reporte1', 'Seleccione un archivo Excel',
                accept=c('.xlsx')),
      width = 6
    ),
    sidebarPanel(
      h4("Seleccione el segundo reporte:"),              
      fileInput('reporte2', 'Seleccione un archivo Excel',
                accept=c('.xlsx')),
      width = 6
    ),
    mainPanel(
      tabsetPanel(
        tabPanel("Reporte BCD", tableOutput("reportebcd")),
        tabPanel("Reporte E.CTA", tableOutput("reporteecta")),
        tabPanel("Conciliacion", tableOutput("conciliacion")),
        type = "tabs"
      ),
      width = 12
    )
   )
  )
 )
)

server.R

library(shiny)
library(readxl)
library(dplyr)
library(fuzzyjoin)

shinyServer(function(input, output) {

  data1 <- reactive({
    inFile <- input$reporte1

    if(is.null(inFile))
      return(NULL)
    file.rename(inFile$datapath,
                paste(inFile$datapath, ".xlsx", sep=""))
    read_excel(paste(inFile$datapath, ".xlsx", sep=""), 1)
  })

  data2 <- reactive({
    inFile <- input$reporte2

    if(is.null(inFile))
      return(NULL)
    file.rename(inFile$datapath,
                paste(inFile$datapath, ".xlsx", sep=""))
    read_excel(paste(inFile$datapath, ".xlsx", sep=""), 1)
  })

  output$reportebcd <- renderTable({
    data1()
  }, striped = TRUE, hover = TRUE, rownames = TRUE)

  output$reporteecta <- renderTable({
    data2()
  }, striped = TRUE, hover = TRUE, rownames = TRUE)

  selectedData <- reactive({
    r_bcd <- data1()
    r_ecta <- data2()
    regex_inner_join(r_bcd, r_ecta, by = c(Orden.de.Servicio = "NUM_DE_ORDEN_DE_SERVICIO", Tarifa.Total = "CANTIDAD"))
  })

  output$conciliacion <- renderTable({
    selectedData()
  }, striped = TRUE, hover = TRUE, rownames = TRUE)

})

Any help would be greatly appreciated. Thanks.

zx8754
  • 52,746
  • 12
  • 114
  • 209
  • Why use `regex_inner_join` if you're not using regex? This should work: `dplyr::inner_join(r_bcd, r_ecta, by = c("NUM_DE_ORDEN_DE_SERVICIO" = "CANTIDAD"))` – JohnCoene Aug 10 '18 at 06:59
  • A reason to use regex inner join would be that the columns do not perfectly match for all entries? – Arthur Yip Mar 17 '19 at 21:00
  • @ArthurYip Exactly – Jacob Nunez Mar 19 '19 at 06:09
  • @JacobNunez To get help, try to break down your problem into a minimally reproducible problem (with some sample data in R format). Is the problem in the data? in the Shiny implementation? Which step does the error occur in? – Arthur Yip Mar 19 '19 at 06:12
  • Basically, there's too much here for us to figure out, especially without being able to run it ourselves. The error message could be because of many possibilities. – Arthur Yip Mar 19 '19 at 06:13

0 Answers0