timelyportfolio / buildingwidgets

repo for a htmlwidget a week documented at https://buildingwidgets.com
https://timelyportfolio.github.io/buildingwidgets/
MIT License
63 stars 12 forks source link

Request: Some sort of form #32

Closed kferris10 closed 9 years ago

kferris10 commented 9 years ago

If you're still looking for requests, I'd like to put one for some sort of way to store user-inputted data. I know that forms exist out there, but it's be nice to be able to set up some way of storing user entered data using R!

smartinsightsfromdata commented 9 years ago

@kferris10 Have a look at rhandsontable by @jrowen - the best implementation of an excel-like grid with cell data entry (to my knowledge). It is still work-in-progress but nearly there.

kferris10 commented 9 years ago

Great call. That's perfect for data entry.

But it'd be nice to be able to export the table to a csv. I don't think that rhandsontable has an implementation for this, though I could be wrong. I'm thinking something like this

smartinsightsfromdata commented 9 years ago

@kferris10 As an alternative you can use DT. See the export to csv etc. implementation at the end of the page here. The problem is that DT does not offer data entry. Or you can use rhandsontable and add in shiny a button to export to whatever format... Perhaps @timelyportfolio (who knows much better than most theJS libraries market) has better ideas?

jrowen commented 9 years ago

In theory it should be possible to implement export to csv functionality. Here is an example of how the logic might work. The handsontable right-click context menu is customizable and could be a good place to place the "Export to CSV" menu option (as opposed to creating a button).

smartinsightsfromdata commented 9 years ago

@jrowen sounds like a very promising solution. I agree that a context menu is better than a button (all in client-side logic!).

jrowen commented 9 years ago

I attempted to add an export to csv option to the widget. Please let you know your thoughts/suggestions (ideally via a new rhandsontable issue).

kferris10 commented 9 years ago

Cool! I'll try it out this weekend.

I'm staying on this thread because I have one last tweek to my request. Would it be possible to have the user's data entered directly into R? So, for example, you could have a table in which the user enters data and then an R plot is generated based on this table? I realize this is fairly simple to do with Shiny, but I'd like to be able to do this outside of a ShinyApp as well.

I can put together an example of what I'm talking about if this isn't clear.

jrowen commented 9 years ago

Without Shiny running, I don't think this is possible with the local R session, but maybe others have a suggestion.

It should be possible to tie handsontable to another Javascript charting library (see this example). All the plumbing would need to be done in Javascript, so I'm not sure if it would make sense to build this as a widget or just create an html app directly.

Another option would be to use a REST API like opencpu to generate a plot (or build a custom Python flask-rpy2 app). It would be relatively easy to add another option to the right-click context menu to POST the table data to an API function call and then download or display the returned image. Setting up an API server can be complicated, so in the end, it may be easier to build a Shiny app.

kferris10 commented 9 years ago

Thanks for all your help guys. I'm closing this issue for now.