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 = as.data.frame(read.delim(inFile$datapath))
    rhandsontable(DF, width = 550, height = 300)

but I get the message:

Warning: Error in as.data.frame.default: 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?

EDIT:
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.
sunseApplication DesignerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sunseApplication DesignerAuthor Commented:
This is an excellent implementation of rhandsone table from the gitHub.  Hope it will help.

library(shiny)
library(rhandsontable)

ui <- fluidPage(
  titlePanel("Handsontable"),
  titlePanel("Edit data file"),
  
  sidebarLayout(
    sidebarPanel(
      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"))
    ),
    mainPanel(
      rHandsontableOutput("hot", width = 1500)
    )
  )
)

server <- function(input, output){
  
  fname = tempfile(fileext = ".tsv")
  observe({
    input$saveBtn
    hot = isolate(input$hot)
    if (!is.null(hot)) {
      write.table(hot_to_r(input$hot), fname)
      print(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)
      else
        DF = values[["DF"]] 
        DF = read.csv("glycoPipe_PARAMS_TEMPLATE.tsv", stringsAsFactors = FALSE)
        
    }
    
    values[["DF"]] = 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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunseApplication DesignerAuthor Commented:
The question has been updated with a solution to the problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
R

From novice to tech pro — start learning today.