colnames函数中的错误:属性的长度必须与向量的长度相同

时间:2020-02-24 07:55:32

标签: r shiny shinyapps

我在用r Shiny定义列名时遇到了麻烦。相同的语法在我的代码的其他部分也起作用,但是在我的代码的这一部分似乎有麻烦。

readFile1 <- reactive({
  rbindlist(lapply(input$file1$datapath, function (x) XLConnect::readWorksheetFromFile(x, sheet = 1, startRow = 8, endRow = -5, startCol = 0, endCol = 26, header = TRUE)), use.names = TRUE, fill = TRUE)
})

renameReadFile1 <- reactive({
  readfile <- data.frame(readFile1())
  if (input$samplesheetType == "old"){
    colnames(readfile) <- c("Well", "Sample Name","Target Name","Task", "Reporter", "Quencher","RQ",    "RQ Min",   "RQ Max",   "CT",   "CT Mean",  "CT SD",    "dCT",  "dCT Mean", "dCT SE",   "HK Control dCT Mean",  "HK Control dCT SE",    "ddCT", "Automatic CT Threshold",   "CT Threshold", "Automatic Baseline",   "Baseline Start",   "Baseline End", "Efficiency",   "Comments", "HIGHSD")
  } else if (input$samplesheetType == "new"){
    colnames(readfile) <- c("Well", "Sample Name","Target Name","Task", "Reporter", "Quencher", "CT",   "CT Mean",  "CT SD",    "Quantity", "Quantity Mean", "Automatic", "CT Threshold")
    }
  readfile
})

我得到的错误是:

Warning: Error in <-: 'names' attribute [13] must be the same length as the vector [0]

但是,我的应用程序上呈现的数据表显示了重命名的列,尽管它没有向下游注册,但我在分析中使用了重命名的列名。任何帮助将不胜感激!

0 个答案:

没有答案
相关问题