简体   繁体   English

警告:match.arg中的错误:'arg'必须为NULL或字符向量

[英]Warning: Error in match.arg: 'arg' must be NULL or a character vector

I am trying to select the cell in the DataTable and show the corresponding position/value. 我试图在DataTable中选择单元格并显示相应的位置/值。 But it seems not working... I ran the code from the example cell code from Yihui but still showing the same error as I got from my code: 但这似乎不起作用...我从Yihui的示例单元代码中运行了代码,但仍然显示出与从代码中得到的错误相同的错误:

Warning: Error in match.arg: 'arg' must be NULL or a character vector Stack trace (innermost first): 76: match.arg 75: datatable 74: widgetFunc 73: func 72: renderFunc 71: output$x16 4: 3: do.call 2: print.shiny.appobj 1: 警告:match.arg中的错误:'arg'必须为NULL或字符向量堆栈跟踪(最里面优先):76:match.arg 75:数据表74:widgetFunc 73:func 72:renderFunc 71:output $ x16 4:3 :do.call 2:print.shiny.appobj 1:

Below are part of my code. 以下是我的代码的一部分。

biTableMatrix function - It assign the values to a certain position in the matrix/df by the xpos (row) and ypos (column). biTableMatrix函数-通过xpos(行)和ypos(列)将值分配到矩阵/ df中的某个位置。 Firstly it returned a matrix, but I thought the error might be caused by the object type (matrix instead of data.frame from the example), so I convert it to data.frame - not much help thou... 首先,它返回一个矩阵,但是我认为该错误可能是由对象类型(矩阵而不是示例中的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)

For reference, here is my ui.R 供参考,这是我的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"
  )
)

Any help would be much appreciated!! 任何帮助将非常感激!!

Thanks!! 谢谢!!

devtools::install_github('rstudio/DT')

不要使用Cran DT。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 match.arg(regions) 中的错误:“arg”必须为 NULL 或字符向量 - Error in match.arg(regions) : 'arg' must be NULL or a character vector match.arg(opt_crit)中的错误:“ arg”必须为NULL或字符向量 - Error in match.arg(opt_crit) : 'arg' must be NULL or a character vector 运行应用程序时出现闪亮错误:match.arg(position) 中的错误:&#39;arg&#39; 必须为 NULL 或字符向量 - Shiny Error when running App: Error in match.arg(position) : 'arg' must be NULL or a character vector Shiny 应用程序中的“match.arg(position) 错误:‘arg’必须为 NULL 或字符向量” - "Error in match.arg(position) : 'arg' must be NULL or a character vector" in Shiny app match.arg(p.adjust.method)中的错误:“ arg”必须为NULL或字符向量 - Error in match.arg(p.adjust.method) : 'arg' must be NULL or a character vector match.arg(position) 中的闪亮错误:“arg”必须为 NULL 或字符向量 - shiny Error in match.arg(position) : 'arg' must be NULL or a character vector 尝试运行以下代码中的插补函数时,“match.arg(what) 中的错误:&#39;arg&#39; 必须为 NULL 或字符向量” - "Error in match.arg(what) : 'arg' must be NULL or a character vector" when trying to run the impute function in the below code match.arg(mvnTest)中的错误:“ arg”的长度必须为1 - Error in match.arg(mvnTest) : 'arg' must be of length 1 &#39;arg&#39;必须为NULL或字符向量 - 'arg' must be NULL or a character vector T 检验错误 'arg' 必须是 NULL 或字符向量 - T-test error 'arg' must be NULL or a character vector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM