rhandsontable
rhandsontable copied to clipboard
Warning: Error in seq.default: argument 'length.out' must be of length 1
I'm deploying a shinyapp and I am using rhandsontable to edit some table in the UI
No problem if I change some values. The table is rendered properly.
The problem seems to rise with the hot_to_r() function in particular:
ph <<- hot_to_r(hotpheno)
where hotpheno is my table.
I tried to use the latest version deployed as suggested in the issue #166 but in vain
The following are some environment reports: RStudio.Version() To cite RStudio in publications use:
RStudio Team (2018). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA URL http://www.rstudio.com/.
A BibTeX entry for LaTeX users is
@Manual{, title = {RStudio: Integrated Development Environment for R}, author = {{RStudio Team}}, organization = {RStudio, Inc.}, address = {Boston, MA}, year = {2018}, url = {http://www.rstudio.com/}, }
$mode [1] "desktop"
$version [1] ‘1.2.1335’
Browse[1]> Sys.getenv() ALLUSERSPROFILE C:\ProgramData APPDATA C:\Users\abbat\AppData\Roaming CLICOLOR_FORCE 1 CommonProgramFiles C:\Program Files\Common Files CommonProgramFiles(x86) C:\Program Files (x86)\Common Files CommonProgramW6432 C:\Program Files\Common Files COMPUTERNAME IMMUNOPC ComSpec C:\WINDOWS\system32\cmd.exe DISPLAY :0 DriverData C:\Windows\System32\Drivers\DriverData GFORTRAN_STDERR_UNIT -1 GFORTRAN_STDOUT_UNIT -1 GSL_INC D:\Apps\GnuWin32\include GSL_LIB D:\Apps\GnuWin32\lib HOME D:/Bio/IT/Project HOMEDRIVE C: HOMEPATH \Users\abbat JAVA_HOME C:\Program Files\Java\jre1.8.0_201 LANGUAGE en LOCALAPPDATA C:\Users\abbat\AppData\Local LOGONSERVER \IMMUNOPC MSYS2_ENV_CONV_EXCL R_ARCH NUMBER_OF_PROCESSORS 8 OS Windows_NT PATH C:\Anaconda3;C:\Anaconda3\Scripts;C:\Anaconda3\Library\bin;C:\R\R-3.5.3\bin\x64;c:\Rtools\bin;c:\Rtools\mingw_64\bin;D:\ImageMagick-7.0.8-Q16;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;D:\Apps\GnuWin32\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Java\jre1.8.0_181\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\PuTTY;C:\Users\abbat\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jre1.8.0_201\bin;C:\R\R-3.5.2\bin\x64;C:\Program Files\Pandoc;C:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin;C:\R\R-3.5.2\bin;C:\Users\abbat\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64;C:\Users\abbat\AppData\Local\GitHubDesktop\bin PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE AMD64 PROCESSOR_IDENTIFIER Intel64 Family 6 Model 158 Stepping 9, GenuineIntel PROCESSOR_LEVEL 6 PROCESSOR_REVISION 9e09 ProgramData C:\ProgramData ProgramFiles C:\Program Files ProgramFiles(x86) C:\Program Files (x86) ProgramW6432 C:\Program Files PSModulePath C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules; PUBLIC C:\Users\Public QT_D3DCREATE_MULTITHREADED 1 R_ARCH /x64 R_COMPILED_BY gcc 4.9.3 R_DOC_DIR C:/R/R-35~1.3/doc R_HOME C:/R/R-35~1.3 R_LIBS C:\R\R-3.5.2\library R_LIBS_USER D:/Bio/IT/Project/R/win-library/3.5 R_PACKRAT_DEFAULT_LIBPATHS C:/R/R-3.5.3/library R_PACKRAT_SYSTEM_LIBRARY C:/R/R-35~1.3/library R_SESSION_INITIALIZED PID=14756:NAME="reticulate" R_USER D:/Bio/IT/Project RETICULATE_PYTHON C:\Anaconda3 RETICULATE_REQUIRED_MODULE umap RMARKDOWN_MATHJAX_PATH C:/RStudio/resources/mathjax-26 RS_LOCAL_PEER \.\pipe\15443-rsession RS_RPOSTBACK_PATH C:/RStudio/bin/rpostback RS_SHARED_SECRET 63341846741 RSTUDIO 1 RSTUDIO_CONSOLE_COLOR 256 RSTUDIO_CONSOLE_WIDTH 80 RSTUDIO_MSYS_SSH C:/RStudio/bin/msys-ssh-1000-18 RSTUDIO_PANDOC C:/RStudio/bin/pandoc RSTUDIO_SESSION_PORT 15443 RSTUDIO_USER_IDENTITY abbat RSTUDIO_WINUTILS C:/RStudio/bin/winutils SESSIONNAME Console SystemDrive C: SystemRoot C:\WINDOWS TEMP C:\Users\abbat\AppData\Local\Temp TERM xterm-256color TMP C:\Users\abbat\AppData\Local\Temp TZDIR C:/R/R-35~1.3/share/zoneinfo USERDOMAIN IMMUNOPC USERDOMAIN_ROAMINGPROFILE IMMUNOPC USERNAME abbat USERPROFILE C:\Users\abbat windir C:\WINDOWS
This error does not appear to be related to hot_to_r(). But just to be sure, are you using the hot_to_r() function inside another custom function? In my experience, hot_to_r() does not play nice inside custom functions. It is better to use it directly in your server functions (main server function or module server functions). Last, setting global variables in Shiny is not ideal in most cases. It might be in your case but you may want to reconsider.
Hi Gueyenono, I report here the reactive function in which I call the hot_to_r():
observeEvent(eventExpr = input$runMetaload, handlerExpr = {
validate(need(expr = !is.null(meta.table()), message = "It needs valid FCS files"))
hotmeta <- input$hot_meta
if (!is.null(hotmeta))
{mt <<- hot_to_r(hotmeta)
uni.condition <<- length(unique(mt$condition))
uni.patient_id <<- length(unique(mt$patient_id))
uni.time_step <<- length(unique(mt$time_step))
color.condition <<- set_colors(uni.condition)
color.patient_id <<- set_colors(uni.patient_id)
color.time_step <<- set_colors(uni.time_step)
}
meta.table(mt)
})
Would you please try to use input$hot_meta
directly in the if
statement?
just did it. It didn't work. Same output. Actually the table that do not respond is this one:
observeEvent(eventExpr = input$runPhenoTableload, handlerExpr = {
#validate(need(expr = !is.null(meta.markers()), message = "It needs valid marker entries"))
hotpheno <- input$hot_pheno
ph <<- hot_to_r(hotpheno)
if (!is.null(hotpheno))
{
#ph <<- hot_to_r(hotpheno)
uni.pheno <<- nrow(ph) - 3
validate(need(expr = (uni.pheno>1), message = "please choose some lineage markers"))
color.pheno <<- set_colors(uni.pheno)
}
pheno.table(ph)
})
The other two tables works just fine but I do not need to extend the number of rows on the other two. As you can see I tried to extract the statement as you suggest but in vain. Just tell me which other report I can provide you. Maybe a snapshot of the status of the code inside the function. I used an efficient method to do that in the past, but I forgot which was the trick. Maybe you can recall it for me, so I can help you with this
Same problem here, can't add row. Error in seq.default: argument 'length.out' must be of length 1
I think I figured out what's wrong. Insert rows need feed back to rhandsontable input value right away after edting. For example:
The following code won't work.
library(rhandsontable)
library(shiny)
ui <- fluidPage(
rHandsontableOutput("data")
)
server <- function(input, output, session) {
rv <- reactiveValues(data = head(cars))
output$data = renderRHandsontable({
rhandsontable(rv$data)
})
observeEvent(input$data, {
if (!is.null(input$data)) {
data <- hot_to_r(input$data)
print(data)
}
})
}
shinyApp(ui, server)
But the following code is working just fine by adding
rv$data <- data:
library(rhandsontable)
library(shiny)
ui <- fluidPage(
rHandsontableOutput("data")
)
server <- function(input, output, session) {
rv <- reactiveValues(data = head(cars))
output$data = renderRHandsontable({
rhandsontable(rv$data)
})
observeEvent(input$data, {
if (!is.null(input$data)) {
data <- hot_to_r(input$data)
print(data)
rv$data <- data
}
})
}
shinyApp(ui, server)
I had the same error, each time after adding a row. For me it was fixed by assigning the rownames(data) to NULL before putting it in the rhandsontable function, as mentioned here.
rownames(data) <- NULL
rhandsontable(data)
I had the same issue, and setting rownames to null did the trick.