REditorSupport / vscode-R

R Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=REditorSupport.r
MIT License
1.06k stars 125 forks source link

Enhance the data viewer #506

Closed renkun-ken closed 3 years ago

renkun-ken commented 3 years ago

Currently, we are using DataTables in the WebView as the data viewer with session watcher enabled. It has the following capabilities (but we are not using all of them at the moment):

There are some alternative data viewer widgets that could provide more power features such as column filtering by value or range (like in RStudio), multi-column ordering. I guess we could investigate into this and see if we could provide a more powerful data viewer.

More powerful alternatives:

alex-gable commented 3 years ago

@renkun-ken if the viewer could honor light+dark or the vscode theme it would be incredible. it's a bit blinding cracking it open at night

Ikuyadeu commented 3 years ago

As the related work, vscode-jupyter implements similar function by the react and tsx. Imitating it is cost, but safe for the license issue.

gvelasq commented 3 years ago

@Ikuyadeu I support the idea of porting the vscode-jupyter data viewer. I filed a related issue in vscode-jupyter: https://github.com/microsoft/vscode-jupyter/issues/4604

When I run View(mtcars) in a Jupyter notebook in VS Code Insiders, I get the following error:

ERROR: Error in View(mtcars): 'View()' not yet supported in the Jupyter R kernel

My hope is that the 'not yet' in the error implies that adding R support for the data viewer could already be a priority for vscode-jupyter, in which case porting to vscode-R may be significantly easier if R data structures have already been specified.

For anyone who has not yet done so, I would encourage you to upvote R here: https://github.com/microsoft/vscode-jupyter/issues/1536

gvelasq commented 3 years ago

To follow up on the issue I raised in vscode-jupyter, this very helpful response from a Microsoft employee points to two files that might be a useful starting point: https://github.com/microsoft/vscode-jupyter/issues/4604#issuecomment-772043821

renkun-ken commented 3 years ago

The data viewer of SQL Tools looks good too. The source seems to be at https://github.com/mtxr/vscode-sqltools/blob/master/packages/vscode/webview-provider/index.ts.

image

From https://github.com/mtxr/vscode-sqltools/blob/master/packages/plugins/package.json, it uses DevExpress/devextreme-reactive.

RandomFractals commented 3 years ago

@renkun-ken you might want to try canvas based grids:

https://github.com/TonyGermaneri/canvas-datagrid

https://github.com/fin-hypergrid/core

Handsontable looks really good, but I am not sure their licensing is suitable for vscode extensions needs.

danielbasso commented 3 years ago

I'm using this extension for about one month now and one of the main issues I have is that the current dataframe view methods (using View() or R: Preview Dataframe) is that the have to load all data. As dataframes get bigger these methods start to become slow, unresponsive or even can't be used at all.

One of the nicest features of Rstudio dataframe preview (I know these comparisons to Rstudio are boring, but they are the 'gold standard' for R programming) is that it dynamically loads about 20-30 rows at a time and the first 50 columns; this is nice, because no matter how big your data is, you can have a preview of it and apply some simple filters.

Between View() or R: Preview Dataframe I prefer the latter, because it's prettier, integrates better with the global theme and has better filtering options:

View() (kind of ugly, few filtering options):

image

R: Preview Dataframe (way better looking - similar to RStudio - better filters, but has to load all data and limited to 20 Mb):

image

For me, the R: Preview Dataframe as it is with dynamically loading would be near perfect. As a workaround, right now I do things like previewing my_df[1:100, ] but it's not ideal.

danielbasso commented 3 years ago

@gvelasq @renkun-ken @Ikuyadeu I've been experimenting with the jupyter api for the last two days. Results so far:

image

What do you guys think? Should I proceed? Bad idea? The downside is it requires that the jupyter extension is installed; but my idea would be to default to the current viewer if the extension isn't present.

What I liked so far:

Downsides:

I read the Webview API documentation and unfortunately it seems not very well suited for interactivity (dynamic paging, for example). It is technically possible, but I'm not sure it's the best direction we could go.

Ikuyadeu commented 3 years ago

@danielbasso Thank you for the nice first try. Depending on Jupyter extension is no problem. We are considering connecting some functions to that. We can move these functions to Jupyter extension after it is stabled in this extensions.

gvelasq commented 3 years ago

@danielbasso thanks very much for taking a look at the vscode-jupyter API. The screenshot looks like a great start.

renkun-ken commented 3 years ago

It looks like ag-grid could be used as a better data viewer if we don't rely on external viewers. It has a ag-grid-community distributed under MIT license and is free to use in any production system.

QizhiSu commented 5 months ago

Hello guys, I am wondering if it is possible to show column index when hovering on the header and showing the dimension of the dataframe. I think it can be very useful. By the way, automatic updating of the dataframe if it has been changed is also nice.