Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character column transformed to numeric in hot_to_r #421

Open
chabrault opened this issue Nov 30, 2022 · 0 comments
Open

Character column transformed to numeric in hot_to_r #421

chabrault opened this issue Nov 30, 2022 · 0 comments

Comments

@chabrault
Copy link

I have an issue using hot_col with a specified list of character elements, for some elements. In some cases, the column class is transformed to numeric despite a list of character elements is provided.

Minimal reproducible example:

library(rhandsontable)
shinyApp(
  ui = basicPage(
    tagList(
      h4("Character transformed to numeric"),
      rhandsontable::rHandsontableOutput("t1"),
      verbatimTextOutput("o1"),
      
    )
  ),
  
  server = function(input, output, session) {
    # transformed to numeric if the first two elements are selected
    char_source <- c("0001E","0006E","0002A")
    output$t1 <- rhandsontable::renderRHandsontable({
      rhandsontable::rhandsontable(data.frame(character = c(rep(NA,5)))) %>%
        rhandsontable::hot_col(col="character",type="dropdown",
                               source=char_source, format="character") 
      
    })
    output$o1 <- renderPrint({
      str(rhandsontable::hot_to_r(input$t1))
    })
  }
)

In this example, the source is composed of character elements. If the first two elements are chosen ("0001E" or "0006E"), the column class is transformed to numeric. This does not happen if the last element is selected ("0002A") or if the data frame is initially defined with "" instead of NA.

Thank you for this nice package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant