Open a file for editing and saving using shiny

I can upload a into RStudio server using shiny.  However, I cannot open the file for editing and saving for processing by the R code.  Apparently, the randsontable library function ransdontable() takes as input a dataframe.  I am using the code below: DF =$datapath))
    rhandsontable(DF, width = 550, height = 300)

but I get the message:

Warning: Error in cannot coerce class "c("rhandsontable", "htmlwidget")" to a data.frame

Is there a solution for this, or is there any other way to open and edit file using shiny?

My code was completely wrong. If anyone wants to find more about the R rhandsontable, please post a question. I will be happy to help.
Who is Participating?
sunseConnect With a Mentor Author Commented:
This is an excellent implementation of rhandsone table from the gitHub.  Hope it will help.


ui <- fluidPage(
  titlePanel("Edit data file"),
      helpText("Changes to the table will be automatically saved to the source file"),
      actionButton("saveBtn", "Save"),
      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"))
      rHandsontableOutput("hot", width = 1500)

server <- function(input, output){
  fname = tempfile(fileext = ".tsv")
    hot = isolate(input$hot)
    if (!is.null(hot)) {
      write.table(hot_to_r(input$hot), fname)
  output$hot = renderRHandsontable({
    if (!is.null(input$hot)) {
      DF = hot_to_r(input$hot)
    } else {
      DF = read.table("DataFile.tsv", sep = '\t', stringsAsFactors = FALSE)
    rhandsontable(DF) %>%
      hot_table(highlightCol = TRUE, highlightRow = TRUE)
  values <- reactiveValues()
  data = reactive({
    if (!is.null(input$hot)) {
      DF = hot_to_r(input$hot)
    } else {
      if (is.null(values[["DF"]]))
        DF = data.frame(val = 1:10, bool = TRUE, nm = LETTERS[1:10],
                        dt = seq(from = Sys.Date(), by = "days", length.out = 10),
                        stringsAsFactors = F)
        DF = values[["DF"]] 
        DF = read.csv("glycoPipe_PARAMS_TEMPLATE.tsv", stringsAsFactors = FALSE)
    values[["DF"]] = DF
  output$hot <- renderRHandsontable({
    DF = data()
    if (!is.null(DF))
      rhandsontable(DF, useTypes = as.logical(input$useType), stretchH = "all")

shinyApp(ui = ui, server = server)

Open in new window

sunseAuthor Commented:
The question has been updated with a solution to the problem.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.