DillonHammill / DataEditR

An Interactive R Package for Viewing, Entering Filtering and Editing Data
https://dillonhammill.github.io/DataEditR/
381 stars 40 forks source link

what about a guided tour? #23

Closed ShinyFabio closed 3 years ago

ShinyFabio commented 3 years ago

Hi, I'm building a very complex shiny app and I have some internal data that has to be editable in the future (like adding more rows). My first question is: can I upload and use an "updated .csv file" in order to update my internal data? (some .rda files that came from csv files) I didn't see an "upload button".

Then I have a suggestion for you. Your package looks amazing, but since my app will be used by people with no knowledge of R (and perhaps non-tech savvy people), your package could be a bit difficult to understand without an explanation. I also had to watch some youtube videos to understand some buttons. So what about adding a guided tour? Like with {cicerone} or {rintrojs} packages. With {rintrojs} you can also add only some "help buttons" if you don't like the guided tour idea.

DillonHammill commented 3 years ago

The latest version of DataEditR (on GitHub) does add labels to buttons upon hovering to make it easier to see what each button does. In the long run, I will be putting together a video to describe all the functionality of the package and perhaps add a guided tour as you mentioned.

In terms of your initial question, I suspect that the answer is yes but I will more information from you if I am going to be of any help. Do you have any code you can share? What exactly are you hoping to achieve?

ShinyFabio commented 3 years ago

So the cran version doesn't have these labels yet?

Regarding my first question I wanted to update my default internal data (let's call it "data_2020") with a new file ("data_2021") so like with the rbind() function. I thought that there was the possibility to load a dataset and update it with a new csv file. However I managed to do it by myself (what I was searching for was too specific).

Anyway I have two more question:

1) Since I need your package inside a shiny app, I think I have to use the dataEditServer() and the correlated functions. But why the "shiny version" doesn't have all the buttons and the options that the data_edit() have? Like the filter, the scissors, the sync and so long.

2) I tried the example in the dataEditServer() function. This one:

if (interactive()) {
  ui <- fluidPage(
    dataInputUI("input-1"),
    dataOutputUI("output-1"),
    dataEditUI("edit-1")
  )

  server <- function(input, output, session) {
    data_to_edit <- dataInputServer("input-1")
    data_to_edit <- dataEditServer("edit-1",
                                   data = data_to_edit
    )
    dataOutputServer("output-1",
                     data = data_to_edit
    )
  }

  shinyApp(ui, server)
}

After uploaded the csv file, the table is not displayed. I had to modify the code in this way:

if (interactive()) {
  ui <- fluidPage(
    dataInputUI("input-1"),
    dataOutputUI("output-1"),
    dataEditUI("edit-1")
  )

  server <- function(input, output, session) {
    data_to_edit <- dataInputServer("input-1")
    data_to_edit2 <- dataEditServer("edit-1",
                                   data = data_to_edit
    )
    dataOutputServer("output-1",
                     data = data_to_edit2
    )
  }

  shinyApp(ui, server)
}

So I changed some names and now it works. I don't know if it's my problem or something else.

DillonHammill commented 3 years ago

Thanks for spotting that, there is definitely a typo in that example. I just pushed a fix to GitHub to fix this:

if (interactive()) {
  ui <- fluidPage(
    dataInputUI("input-1"),
    dataOutputUI("output-1"),
    dataEditUI("edit-1")
  )

  server <- function(input, output, session) {
    data_to_edit <- dataInputServer("input-1")
    data_edit <- dataEditServer("edit-1",
                                   data = data_to_edit
    )
    dataOutputServer("output-1",
                     data = data_edit
    )
  }

  shinyApp(ui, server)
}

DataEditR v0.1.3 is available on GitHub and is perfectly fine to use. The only new features are the button labels that I mentioned and row/column highlighting is now turn on when a cell is selected (see video below). I will push these updates to CRAN soon.

DataEditR_v0 1 3

data_edit() makes use of all the modules (dataInput, dataEdit, dataSelect, dataFilter and dataOutput) which bring with them their associated buttons. In addition data_edit() actually maintains 2 copies of the data, the complete original dataset (master copy) and a data subset (filtered by dataSelect and dataFilter). As a result data_edit() has some extra buttons to handle saving of each of the these copies and the extra cut button which trims the original dataset to data subset and makes this the new master copy. The sync button merges changes made in the data subset with the master copy.

I am still not exactly sure what you hope to achieve, but I think that you are trying to add additional rows to a reactive dataset using a CSV file. This is possible through the row_bind argument in dataEdit() but this argument (and col_bind) don't currently support CSV filenames as an input. So you will need to read in the CSV file manually and then pass it to the row_bind argument of your dataEdit module that has your original dataset as its input.

ShinyFabio commented 3 years ago

Oh ok so if I need all the functions of data_edit() I have to use all the modules. Regarding my question, yes that's exactly what I was searching for. I started loading and read the csv file and then manually merge to the other with rbind(). I didn't see the row_bind argument. I will check it! Thanks a lot!

DillonHammill commented 3 years ago

Adding this here for anyone else who may be interested in how the DataEditR modules fit together within data_edit():

DataEditR Modules

ShinyFabio commented 3 years ago

Great! I think you can also put inside the readme! It will have more visibility.