คำเตือน: ข้อผิดพลาดใน match.arg: 'arg' ต้องเป็น NULL หรือเวกเตอร์อักขระ

ฉันกำลังพยายามเลือกเซลล์ใน DataTable และแสดงตำแหน่ง/ค่าที่เกี่ยวข้อง แต่ดูเหมือนว่าจะไม่ทำงาน... ฉันรันโค้ดจาก โค้ดเซลล์ตัวอย่างจาก Yihui แต่ ยังคงแสดงข้อผิดพลาดเดียวกันกับที่ฉันได้รับจากรหัสของฉัน:

คำเตือน: ข้อผิดพลาดใน match.arg: 'arg' ต้องเป็น NULL หรืออักขระเวกเตอร์ Stack Trace (อยู่ด้านในสุดก่อน ): 76: match.arg 75: ตารางข้อมูล 74: widgetFunc 73: func 72: renderFunc 71: output$x16 4: 3: do.call 2: print.shiny.appobj 1:

ด้านล่างนี้เป็นส่วนหนึ่งของรหัสของฉัน

ฟังก์ชัน biTableMatrix - กำหนดค่าให้กับตำแหน่งใดตำแหน่งหนึ่งในเมทริกซ์/df ด้วย xpos (แถว) และ ypos (คอลัมน์) ประการแรกมันส่งคืนเมทริกซ์ แต่ฉันคิดว่าข้อผิดพลาดอาจเกิดจากประเภทวัตถุ (เมทริกซ์แทนที่จะเป็น data.frame จากตัวอย่าง) ดังนั้นฉันจึงแปลงเป็น data.frame - คุณช่วยไม่ได้มาก ...

# The following are in helper.R

travelMeans <- c('02', '04')
prepareTwoMeans <- function(travelMeans) {
  listx <- subset(geodata[geodata$MeanCode==travelMeans[1],], select = -c( AreaFull,MeanName,MeanFull))
  listx <- listx[order(listx$Percentage),] 

  listy <- subset(geodata[geodata$MeanCode==travelMeans[2],], select = -c( AreaFull,MeanName,MeanFull,AreaCode))
  listy <- listy[order(listy$Percentage),] 

  listx$xpos <- seq(length=nrow(listx))
  listy$ypos <- seq(length=nrow(listy))

  listx <- merge(listx, listy, by.x = c("AreaName"), by.y = c("AreaName"), all=TRUE)
  return(listx)  
}

# This function generates the two-way table of two travel means
biTableMatrix <- function(travelMeans) {
  fullList <- prepareTwoMeans(travelMeans)
  len <- length(fullList$AreaName)
  biTableMat <- matrix(data = "", nrow = len, ncol = len, dimnames = list(seq(length = len), seq(length = len)))#, 

  for (n in 1:len) {
    x <- fullList$xpos[n]
    y <- fullList$ypos[n]
    biTableMat[x,y] <- as.character(fullList$AreaName[n]) #fullList$AreaCode[n]
  }

  return(as.data.frame(biTableMat) )
}

# The following are in server.R
  biTable <- reactive({
    return(biTableMatrix(input$travelMeans))
  })

  output$biTable <- DT::renderDataTable({
    DT::datatable(
     biTable()
     , selection = list(mode = "single", target = "cell")
     , extensions = list("Scroller", "RowReorder")
     , options = list(
        scrollX = 500
      , scrollY = 700
      , rowReorder = FALSE
     )      
   )}
    , options = list(
      searchHighlight = TRUE
    )
  )

 output$biTableText <- renderPrint(input$biTable_cells_selected$value)

สำหรับการอ้างอิง นี่คือ ui.R. ของฉัน

#Definte UI for the application
ui <- fluidPage(
sidebarPanel(
    # The following part is groupCheckBox format for the travelMeans
    checkboxGroupInput(
      "travelMeans"
      , label = "Select the mean below:"
      , choices = meanChoices
      , selected = NULL
    )

    , br()
  ),

  #Show the map
  mainPanel(
    tabsetPanel(#type = "tabs",
        tabPanel("Single-Mean Table", DT::dataTableOutput("onetable"), hr())

      , tabPanel("Two-way table", DT::dataTableOutput("biTable"), hr(), verbatimTextOutput("biTableText"))
    )

    , position="center"
   , height= "auto"
  )
)

ความช่วยเหลือใด ๆ ที่จะได้รับการชื่นชมมาก !!

ขอบคุณ!!


person Cococatty    schedule 19.01.2016    source แหล่งที่มา


คำตอบ (1)


devtools::install_github('rstudio/DT')

อย่าใช้แครน DT

person WCMC    schedule 23.02.2016
comment
ขออภัย ฉันหมายความว่าคุณสามารถใช้ DT จาก github ได้เนื่องจากเป็น DT เวอร์ชันที่พัฒนามากที่สุด CRAN DT ได้รับการอัปเดตอย่างช้าๆ - person WCMC; 18.05.2016