内部连接带有两个反应良好的数据框

时间:2018-08-09 22:06:35

标签: r shiny fuzzyjoin

我正在开发R Studio Shiny应用程序,其逻辑在于将两个excel文件加载到数据帧中,并使用Fuzzyjoin包在这些数据帧之间进行内部联接,以下是我的Shiny.r和server,r的代码, excel文件的加载是正确的,但是当我进入Conciliacion选项卡时,我收到错误

  

错误:列col必须是一维原子向量或列表:

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)

})

任何帮助将不胜感激。 谢谢。

0 个答案:

没有答案