jrowen / rhandsontable Goto Github PK
View Code? Open in Web Editor NEWA htmlwidgets implementation of Handsontable.js
Home Page: http://jrowen.github.io/rhandsontable/
License: Other
A htmlwidgets implementation of Handsontable.js
Home Page: http://jrowen.github.io/rhandsontable/
License: Other
When set contextMenu=F, the right-click menu still there.
mtcars %>% rhandsontable() %>% hot_table(contextMenu=F)
R 3.2.1, rhandsontable 0.2
I have been experimenting with hot_validate_numeric and it seems to me that needs to be specified once for each column.
In other words a vector of col names or col indexes does not seem to work as in
rhandsontable(df_, readOnly = FALSE, rowHeaders= NULL, useTypes= TRUE) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE) %>%
hot_validate_numeric(hot = ncols, min = 0, max = 100, allowInvalid = FALSE)
As this is not very idiomatic in R (e.g. the imperative to vectorise!), would it be possible to introduce this feature?
@jrowen Again congrats for a great implementation of this widget.
Few minor questions listed here:
Thanks
Hi first of all thanks for this amazing package!
I am having a hard time in figuring out how to use rhandsontable in an app where i can switch among different tables and save the edited tables to a file.
I followed the example in inst/examples/rhandson_datafile.
I then added a selectInput (with inputID tablename) in the ui.R and modified server.R to read different files depending on input$tablename. If I don't edit the tables, then switching the tables works.
The problem I have is that using !(is.null(input$hot)) prevents the switch if I already edited one of the tables, in which case input$hot is not null. I couldn't come out with a solution and can not set input$hot to null manually when the switch happens (I tried observeEvent(input$tablename, input$hot <- NULL)
but receive an error saying that I am not allowed to do this because it is a read-only value).
Is it possible to add a function to reset input$hot (or whathever other inputID one might choose),
or do you have any workaround for this in mind?
Thanks a lot for the help!
Cheers,
Luca
In Shiny copying single or few columns larger than given table row size and pasting causes error "invalid 'row.names' length".
Thanks
@jrowen I find the validator one of the most interesting things of your implementation (as it makes so much sense to do this client-side). Unfortunately it is not very clear how it works.
typeof(value) == "string" && value > 0
?I may misunderstand this the readOnly parameter, but in shiny when I create a new table and set columns to read only using readOnly = T I am able to right click and make them in the web browser and make them editable.
Is this the intended functionality?
Just like the input$tableId_rows_selected
and input$tableId_row_last_clicked
in DT package.
Thanks for the nice package!
By the way the link to examples in vignettes break out.
Dear all,
First let me congratulate you for this great package, I see many opportunities to use it in my future Shiny apps!
Being quite new to rhandsontable, I have an issue while trying to live-edit an Excel file when some columns are interpreted as factor by R (which is my expected behavior).
As an simple reproducible example (based on your demo rhandsontable_datafile):
library(rhandsontable)
shinyUI(fluidPage(
actionButton("saveBtn", "Save changes"),
rHandsontableOutput("hot")
))
library(rhandsontable)
library(xlsx)
shinyServer(function(input, output, session) {
fname <- "filename"
values = list()
setHot = function(x) values[["hot"]] <<- x
observe({ # will update xlsx file each time the button is pressed
input$saveBtn
if (!is.null(values[["hot"]])) {
write.csv(values[["hot"]], fname)
write.xlsx(x = values[["hot"]], file = paste0(fname, ".xlsx"), row.names = FALSE)
}
})
output$hot = renderRHandsontable({
if (!is.null(input$hot)) {
DF = hot_to_r(input$hot)
setHot(DF)
rhandsontable(DF) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE)
} else {
DF <- read.xlsx2("filename.xlsx", sheetIndex = 1) # DOES NOT WORK
# DF <- read.xlsx2("filename.xlsx", sheetIndex = 1, stringsAsFactors = FALSE) # DOES WORK
setHot(DF)
rhandsontable(DF) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE)
}
})
})
When running the version with the folowing row active
DF <- read.xlsx2("filename.xlsx", sheetIndex = 1)
the following error occurs as soon as I change a cell value:
I would like values to be treated as factors (to have dropdown values proposal). Is that feasible? Could you please let me know how to proceed?
Many thanks in advance for your views on this issue !
Regards
Details at rstudio/shiny#914
Hi,
I am having some trouble with correctly formatting whitespace characters.
Specifically, with the following ui.R and server.R code the dataframe below is produced.
Unfortunately, in the handsontable produced note how the list data are misaligned even though it is formatted with sprintf and trimWhitespace set to false.
Any idea how to correctly format this?
Also, how would I generate the table without the separating comma's?
library(shiny)
library(shinydashboard)
library(rhandsontable)
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
fluidRow( box(title = "Handsontable",rHandsontableOutput("hot") )
))
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$hot = renderRHandsontable({
Y<-data.frame(Names=c("a","b","c","d"),stringsAsFactors=FALSE)
Y$Data=list(c(100,2,300),c(1,20,30),c(10,20,300),c(1,20,3))
Y$Data<-lapply(Y$Data,function(x) sprintf("% 4d",x) )
rhandsontable(Y, rowHeaders=FALSE,trimWhitespace =FALSE)
})
}
Is there a way to set background color when column header is omitted? Take the Conditional Formatting sample code here as an example. It does not seem to work if colHeaders=NULL is added:
MAT = matrix(runif(100, -1, 1), nrow = 10,
dimnames = list(LETTERS[1:10], LETTERS[1:10]))
diag(MAT) = 1
MAT[upper.tri(MAT)] = MAT[lower.tri(MAT)]
rhandsontable(MAT, colHeaders = NULL, readOnly = TRUE) %>%
hot_cols(renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
if (row == col) {
td.style.background = 'lightgrey';
} else if (col > row) {
td.style.background = 'grey';
td.style.color = 'grey';
} else if (value < -0.75) {
td.style.background = 'pink';
} else if (value > 0.75) {
td.style.background = 'lightgreen';
}
}")
Am I missing something here?
Awesome package!! Thanks for putting it together. One potential issue: it seems like a column can't have both a rendered JS input and a format input.
rhandsontable(iris) %>% hot_col(1,format="0%")
rhandsontable(iris) %>%
hot_col(1,renderer="function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.style.background = 'lightgrey';
td.style.fontWeight = 'bold';
}
")
rhandsontable(iris) %>%
hot_col(1,format="0%",renderer="function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.style.background = 'lightgrey';
td.style.fontWeight = 'bold';
}
")
Is this a known issue or an error on my end? Thanks!!!
I could not find an example of actually getting the input from the table. For those who are wondering, it is just like the other inputs using input$ID, where ID is the ID of the object.
My question is whether there is some clever method of getting the table in a useful format. Right now it is returned as a list of lists instead of matrix/data.frame which I was expecting.
Here's the input returned from a simple 3x2 matrix:
$data
$data[[1]]
$data[[1]][[1]]
[1] "1"
$data[[1]][[2]]
[1] "4"
$data[[2]]
$data[[2]][[1]]
[1] "2"
$data[[2]][[2]]
[1] "5"
$data[[3]]
$data[[3]][[1]]
[1] "3"
$data[[3]][[2]]
[1] "6"
$changes
$changes$event
[1] "afterChange"
$changes$changes
$changes$changes[[1]]
$changes$changes[[1]][[1]]
[1] 2
$changes$changes[[1]][[2]]
[1] 1
$changes$changes[[1]][[3]]
[1] 0
$changes$changes[[1]][[4]]
[1] "6"
$params
$params$data
$params$data[[1]]
$params$data[[1]][[1]]
[1] "1"
$params$data[[1]][[2]]
[1] "4"
$params$data[[2]]
$params$data[[2]][[1]]
[1] "2"
$params$data[[2]][[2]]
[1] "5"
$params$data[[3]]
$params$data[[3]][[1]]
[1] "3"
$params$data[[3]][[2]]
[1] "6"
$params$rClass
[1] "matrix"
$params$rColClasses
[1] "numeric"
$params$selectCallback
[1] FALSE
$params$colHeaders
NULL
$params$rowHeaders
NULL
$params$columns
$params$columns[[1]]
$params$columns[[1]]$type
[1] "text"
$params$columns[[2]]
$params$columns[[2]]$type
[1] "text"
$params$width
NULL
$params$height
NULL
$params$contextMenu
$params$contextMenu$items
$params$contextMenu$items$row_above
named list()
$params$contextMenu$items$row_below
named list()
$params$contextMenu$items$hsep1
[1] "---------"
$params$contextMenu$items$col_left
named list()
$params$contextMenu$items$col_right
named list()
$params$contextMenu$items$hsep2
[1] "---------"
$params$contextMenu$items$remove_row
named list()
$params$contextMenu$items$remove_col
named list()
$params$contextMenu$items$hsep3
[1] "---------"
$params$contextMenu$items$undo
named list()
$params$contextMenu$items$redo
named list()
$params$contextMenu$items$hsep4
[1] "---------"
$params$contextMenu$items$make_read_only
named list()
$params$contextMenu$items$alignment
named list()
$params$allowRowEdit
[1] TRUE
$params$allowColEdit
[1] TRUE
$params$csvFileName
[1] "download.csv"
Now, the first part of this long list contains the actual numbers. One can convert it to a matrix like this:
table_rows = length(input$table[[1]])
print(matrix(unlist(input$table[[1]]), nrow = table_rows, byrow = T))
[,1] [,2]
[1,] "1" "4"
[2,] "2" "5"
[3,] "3" "6"
Still, is there some less messy way that I am overlooking?
Not really sure what is going on here. When using rhandsontable
, I get the columns in the wrong order like this:
vs | 4 | 6 | 8 |
---|---|---|---|
1 | 3 | 14 | 0 |
10 | 4 | 1 |
library(dplyr)
library(tidyr)
library(rhandsontable)
mtcars %>%
group_by(vs, cyl) %>%
summarise(num = n()) %>%
spread(cyl, num)
vs 4 6 8
1 0 1 3 14
2 1 10 4 NA
mtcars %>%
group_by(vs, cyl) %>%
summarise(num = n()) %>%
spread(cyl, num) %>%
rhandsontable()
Here's my session info
> devtools::session_info()
Session info ------------------------------------------------------------------------------------------------------
setting value
version R version 3.1.3 (2015-03-09)
system x86_64, mingw32
ui RStudio (0.99.473)
language (EN)
collate English_United States.1252
tz America/New_York
Packages ----------------------------------------------------------------------------------------------------------
package * version date source
assertthat * 0.1 2013-12-06 CRAN (R 3.1.3)
DBI * 0.3.1 2014-09-24 CRAN (R 3.1.3)
devtools * 1.7.0 2015-01-17 CRAN (R 3.1.3)
digest * 0.6.8 2014-12-31 CRAN (R 3.1.3)
dplyr 0.4.1 2015-01-14 CRAN (R 3.1.3)
htmltools * 0.2.6 2014-09-08 CRAN (R 3.1.3)
htmlwidgets * 0.5.1 2015-09-16 Github (ramnathv/htmlwidgets@3a2e312)
jsonlite * 0.9.16 2015-04-11 CRAN (R 3.1.3)
lazyeval * 0.1.10 2015-01-02 CRAN (R 3.1.3)
magrittr * 1.5 2014-11-22 CRAN (R 3.1.3)
Rcpp * 0.11.5 2015-03-06 CRAN (R 3.1.3)
rhandsontable 0.2.2 2015-09-23 Github (jrowen/rhandsontable@d96bf46)
rstudioapi * 0.3.1 2015-09-16 Github (rstudio/rstudioapi@d0417a9)
tidyr 0.2.0 2014-12-05 CRAN (R 3.1.3)
yaml * 2.1.13 2014-06-12 CRAN (R 3.1.3)
Hi, yesterday this code was working fine for me. Now I get some an error when I run the shiny app and try to change some value in the hot table.
Error: attempt to set 'colnames' on an object with less than two dimensions
This is the app:
library(shiny)
library(rhandsontable)
ui = shinyUI(fluidPage(
titlePanel("Handsontable"),
sidebarLayout(
sidebarPanel(
rHandsontableOutput("hot")
),
mainPanel(
verbatimTextOutput("debug"),
#tableOutput("table"),
br()
)
)
))
server = function(input, output) {
data <- reactive({
if (is.null(input$hot)) {
DF = data.frame(val = 1:10, bool = TRUE, nm = LETTERS[1:10],
dt = seq(from = Sys.Date(), by = "days", length.out = 10),
stringsAsFactors = F)
} else {
DF = hot_to_r(input$hot)
}
DF
})
output$hot <- renderRHandsontable({
DF <- data()
rhandsontable(DF, useTypes = FALSE, selectCallback = TRUE)
})
output$table <- renderTable({data()})
### DEBUG
output$debug <- renderPrint({
str(input$hot_select$select)
})
}
shinyApp(ui = ui, server = server)
It would be great if you could take a look, thanks!
Hi Jonathan,
We posted this issue in the stackexchange to no avail. Wondering if this feature is supported or not.
http://stackoverflow.com/questions/31863518/linking-shiny-actionbutton-and-rhandsontable
Thank you!
Hello, thank you for your excellent work to create this package! I'm starting to use it within a Shiny application and I'd like any new rows to be pre-populated with some template values as seen in this example from the handsontable documentation. I didn't see any parameters in hot_table
to accomplish this, but it would be a great feature to have. Let me know if you'd like me to provide more details on this idea.
@jrowen I just run a trace between client and server in shiny to see what is exchanged.
I can see that the table data gets back and forth between client and server. I guess there are pos and cons with each approach. On the other hand I was surprised to see that even just selecting a cell with the mouse (without writing anything) was generating the data to be sent to the server.
Do you plan (long term maybe?) to study an optimisation of this?
E.g. you are familiar with trestletech approach (and its pitfall)...
Did you take down the export to csv branch?
When columnSorting=T
manually sorting columns seem to affect row indices, so any subsequent call to input$tableId_select$select$r
will return data for the wrong row. Best would be to ensure that input$tableId_select$select$r
always returns the underlying data.frame's row.name
.
Hi, in my code when I add a row via the context menu the table doesn't expand.
The rows are added (I see them in the data.frame if I debug) but they aren't displayed.
In the examples they are displayed (the table extends) but I can't find the property that controls this feature.
It seems related to the boundaries of the table. For example, If I have a column with a autocomplete feature, the menu doesn't go beyond the table (it's cut). It seems that the table can't draw anymore than it's initial boundary. I'm using a sidebar layout
A minimal example:
library(shiny)
library(rhandsontable)
library(D3TableFilter)
server = shinyServer(function(input, output, session) {
output$ht <- renderRHandsontable({
rhandsontable( data.frame( a = 1:5 ) )
})
})
ui = shinyUI(fluidPage(
rHandsontableOutput("ht"),
d3tfOutput('d3t')
))
runApp( shinyApp(ui, server) )
If I run the app as it is, the resulting table will have 7 rows in total with 2 blank rows at the bottom. If I remove the line d3tfOutput('d3t')
, the table has 5 rows. Any suggestions how one (empty) table manipulates the other?
If there are multiple calls to rHandsontableOutput, in the built=in browser only one of them will show. For example, this happens with the data file editor example - if I copy it into RStudio and execute it, I will only see one of the tables.
The page looks fine in Chrome, so it is easy to work around this by calling runApp( launch.browser=TRUE, ...), So no urgency about solving it. Since I never experienced the problem with shinytable, I figured I should tell you about it.
Hello jrowen,
I have a doubt when I use the next example,
MAT = matrix(rnorm(50), nrow = 10, dimnames = list(LETTERS[1:10],
letters[1:5]))
rhandsontable(MAT * 10) %>%
hot_validate_numeric(col = 1, min = -2, max = 4, exclude = 40,allowInvalid = FALSE)
It says: "Invalid data cells will be color red" but when I execute the example, the cell values which are out of range (-2,4) does not have any red color.
Help me if I have an error.
Thank so much in advance and congratulations for this amazing package!!.
Hi,
when adding read only property for cols, example not working properly, but hot_table(readOnly = TRUE) is ok.
library(shiny)
library(rhandsontable)
ui = shinyUI(fluidPage(
titlePanel("Handsontable"),
sidebarLayout(
sidebarPanel(
helpText("Handsontable demo output. Column add/delete does work ",
"for tables with defined column properties, including type."),
radioButtons("useType", "Use Data Types", c("TRUE", "FALSE"))
),
mainPanel(
rHandsontableOutput("hot")
)
)
))
server = function(input, output) {
output$hot <- renderRHandsontable({
if (is.null(input$hot)) {
DF = data.frame(val = 1:10, bool = TRUE, nm = LETTERS[1:10],
dt = seq(from = Sys.Date(), by = "days", length.out = 10),
stringsAsFactors = F)
} else {
DF = hot_to_r(input$hot)
}
rhandsontable(DF, useTypes = as.logical(input$useType)) %>%
# hot_table(readOnly = TRUE) # ok
hot_col(col = 1, readOnly = TRUE)
})
}
shinyApp(ui = ui, server = server)
Thanks
None of the shiny examples works for me.
I have an error in JSconsole instead,
Uncaught TypeError: Cannot read property 'data' of undefined
rhandsontable.js:98
Uncaught TypeError: Cannot read property 'updateSettings' of undefinedrhandsontable.js:98 HTMLWidgets.widget.resizehtmlwidgets.js:62 superFuncBoundhtmlwidgets.js:411 (anonymous function)shiny.js:2891 (anonymous function)shiny.js:116 (anonymous function)shiny.js:3239 (anonymous function)jquery.js:374 n.extend.eachjquery.js:139 n.fn.n.eachshiny.js:3238 mshiny.js:232 $invokeshiny.js:214 (anonymous function)
Uncaught TypeError: Cannot read property 'data' of undefined
rhandsontable.js:98 Uncaught TypeError: Cannot read property 'updateSettings' of undefined
my sessionInfo() is:
R version 3.2.0 (2015-04-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.1 LTS
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.9.4 metricsgraphics_0.7.5 htmltools_0.2.6
[4] htmlwidgets_0.3.3 rhandsontable_0.0.2 shiny_0.11.1
loaded via a namespace (and not attached):
[1] Rcpp_0.11.5 digest_0.6.8 mime_0.3 chron_2.3-45
[5] R6_2.0.1 plyr_1.8.2 xtable_1.7-4 jsonlite_0.9.16
[9] magrittr_1.5 reshape2_1.4.1 tools_3.2.0 RJSONIO_1.3-0
[13] stringr_0.6.2 yaml_2.1.13 httpuv_1.3.2
The shiny
input binding has not been implemented in htmlwidgets
yet.
I have enabled allowColEdit and allowRowEdit. This makes it possible to add new rows, but not new columns. I'm not sure if I'm missing something or it's a bug. The menu options show up correctly, but nothing happens when clicking them.
It happens with this Shiny: https://github.com/Deleetdk/Jensens_method_2
Specifying colHeaders
clears data from table cells
For example
libray(dplyr)
iris %>% tbl_df() %>% rhandsontable
Warning message:
In if (rClass == "matrix") { :
the condition has length > 1 and only the first element will be used
I'm not sure if this is worth fixing, but I thought I'd mention in case you hadn't seen this before :)
Great package!
Some issues with shinydashboard (I confess I haven't tried to reproduce them in "plain" shiny)
I'm sure some of them are due to improper parameter settings from my part?
library(shiny)
library(shinydashboard)
library(rhandsontable)
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
fluidRow(
box(plotOutput("plot1")),
box( title = "Controls", width=3,sliderInput("slider", "Number of observations:", 1, 10, 5) )),
fluidRow( box(title = "Handsontable",rHandsontableOutput("hot") )
))
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
values <- reactiveValues()
setHot <- function(x) values[["hot"]] <- x
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$hot = renderRHandsontable({
if (!is.null(input$hot)) {
DF <- hot_to_r(input$hot)
setHot(DF)
rhandsontable(DF) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE)
} else {
DF <- mtcars
cols <- colnames(DF)
DF$brand <- row.names(mtcars)
DF <- DF[,c("brand", cols)]
rhandsontable(DF, rowHeaders=FALSE) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE) %>%
hot_cols(columnSorting = TRUE, fixedColumnsLeft=1) %>%
hot_validate_numeric(col = "mpg", allowInvalid=FALSE)
}
})
}
shinyApp(ui, server)
Thanks!
My table does several calculations. Whenever a user inputs a change, I want to change only the cells that depend on the changed cell. Is that possible? Is there a parameter that specifies which cell has been changed?
The table is not appearing on the shiny
example.
The scenario is like this:
The values in the table depend on some input variable. If start the app, and change the input variable, the table doesn't react. The way to make it react is to change some value in the table first. After that, changing other input variables makes the table react. But you have to change some value in the table first.
This is in version 0.2.1
Usage/difference is not clear.
@jrowen Congrats for this very neat implementation of handsontable!
I haven't tested it fully yet (watch this space!), but in the shiny.R example I notices the error message below with (probably after shiny recent adoption of jsonlite):
Input to asJSON(keep_vec_names=TRUE) is a named vector.
In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects.
If you want JSON object output, please use a named list instead. See ?toJSON.
http://rpubs.com/jrowen/intro_rhandsontable
The links to the shiny examples do not work. Instead they return an XML error.
Hi,
I'm using rhandsontable to display and edit .csv files in a Shiny app, and the file that is displayed in the table depends on the value of selectInput. When I first load the app, if I change the file I want to display using the selectInput, the rhandsontable changes properly. But once I double click into the table or make any edits, changing the value of selectInput no longer changes what .csv file is displayed in the rhandsontable, it just displays whatever file was shown when I clicked into/edited it. I know this is because once I've clicked/edited, the rHandsontableOutput is no longer considered null, but is there a way around this so I can use the same table to edit multiple files? Setting input$file <- NULL
seems like it would solve it, but isn't possible.
I have the following in my shiny server.R:
hotvalues = reactiveValues()
setHot = function(x) hotvalues[["file"]] <<- x
rHandsontableOutput("file")
And my output$file <- renderRHandsontable
looks generally like this:
if (!is.null(input$file)) {
hotdf = hot_to_r(input$file)
setHot(hotdf)
rhandsontable(hotdf) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE,
allowRowEdit=FALSE, allowColEdit=FALSE)
} else {
hotdf <- read.csv(filefromselectInput), stringsAsFactors = FALSE)
setHot(hotdf)
rhandsontable(hotdf) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE,
allowRowEdit=FALSE, allowColEdit=FALSE)
}
Hi, very useful JS bindings!
I just noticed that when numeric columns contain NA or NaN values, then the renderer breaks (reads numeric columns as text). In that case I have to manually set column types and formats. Is this behavior by design? Also I'm wondering what's the best way to render NA and NaN to something nicer on the client, like "--" or "no data", etc.
Thanks, --Mel.
Hi! Some time ago this seemed to work perfectly fine, but now it doesn't. I have a table with mixed datatypes and some blank cells. Then the table is bound to a reactive value, which then is used in calculations. Now, however I either don't get any reaction whatsoever or have the error message no method or default for coercing “character” to “factor”. When I specify useTypes=FALSE, there is reaction, but then I have to work with a messy string. Is there a way to specify that all data in the table should be strings?
THanks!
In the example below, the tables don't re-size when the browser window size changes and may overlap.
shiny::runGitHub("rhandsontable", "jrowen", subdir="inst/examples/rhandsontable_dash")
Hi
I'd love to use the minSpareRows: 1 option as in the first example in http://handsontable.com/ but haven't figured out how to do it with rhandsontable.
How can I get it to work?
Best
var
data = [
['', 'Maserati', 'Mazda', 'Mercedes', 'Mini', 'Mitsubishi'],
['2009', 0, 2941, 4303, 354, 5814],
['2010', 3, 2905, 2867, 412, 5284],
['2011', 4, 2517, 4822, 552, 6127],
['2012', 2, 2422, 5399, 776, 4151]
],
container = document.getElementById('example'),
hot;
hot = new Handsontable(container, {
data: data,
minSpareRows: 1,
colHeaders: true,
contextMenu: true
});
there doesn't seem to be a way to call hot_to_r() if the table contains a column of type dropdown.
for example:
server.R -
shinyServer(function(input, output) {
output$saveButton <- downloadHandler(
filename=function() { paste0(Sys.Date(), '.csv') },
content = function(file) {
hot.df <- hot_to_r(input$table)
write.csv(hot.df, file=file)
}
)
output$table <- renderRHandsontable({
df <- data.frame( a = "")
rhandsontable(df, rowHeaders = NULL) %>%
hot_col("a", type = "dropdown", source = list("hello", "world"))
})
})
gives the error:
no method or default for coercing “character” to “factor”
I use the following code (modified from the examples) in the rstudio viewer:
rhandsontable(MAT, width = 300, height = 150) %>%
hot_cols( fixedColumnsLeft = 1) %>%
hot_rows( fixedRowsTop = 1)
I would expect to see e.g. the left-most column fixed when scrolling, but the left column appears only highlighted. Same for top row.
On the other hand when I publish it on a web page is behaves as expected (I haven't got around to try it with knitr).
I was wondering how the hot_to_r function works. I am using data.table with 2 columns which are characters and a varying number of columns which are all numeric. It seems that when using hot_to_r, all columns are coerced to numeric, resulting in a messed up table. Can I pass an argument in the function to keep the types of columns?
Hi I have come across another issue. I have a dynamic data frame in Shiny. And again - a week ago it was working fine, and now it doesn't :)
In the dynamic data frame the number of rows changes, and it used to automatically update the number of rows in the handsontable, but now it doesn't
I am having trouble understanding how to obtain the edited table from the ui.R once it a table is edited in a shiny app implementation of rhandsontable. Are there examples of this? I would like to be able to use the user edits in downstream calculations, so obtaining them is the first step.
@yihui I'm wondering if you might have a suggestion here. It appears that the switch to jsonlite is breaking the row and column add functionality in shiny.
If you run the basic shiny example and add a row, you'll see that the new row is returned to shiny as NULL values (see toR function), and then the unlist function drops the new row. It seems that these NULL values must be converted to NA to be stored in a data.frame, and when the data.frame is returned to the widget, these NA values then need to be converted to NULL so they display as empty cells in the widget.
This logic appears to handle the NA conversion, but then I'm left with NA values in the widget.
out = lapply(out, function(x) lapply(x, function(x) ifelse(is.null(x), NA, x)))
The column add is creating a character vector.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.