-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add release post for webR 0.3.1 #689
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is so great to see webR become mature software 😄
|
||
<div class="output error"> | ||
|
||
Uncaught Error: Error in sin("abc"): non-numeric argument to mathematical function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the post and not terribly important but could the call be backticked? Less consistent with base R but to be perfectly consistent we'd need a space between the call and semi-colon, I think it's better to follow the tidyverse style here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I don't think we need it to be entirely consistent with base R and I like the idea of using tidyverse style with backticks. I've made an issue to track this: r-wasm/webr#397 for next patch release.
|
||
### R `data.frame` | ||
|
||
JavaScript objects of shape `{ x: [...], y: [...] }`, with data in a "long" column-based form, can now be used to construct R objects. In previous versions of webR, this object shape was reserved for future use. However, with this release webR now constructs an R `data.frame` by taking the source object's properties as column vectors. The resulting `data.frame` can then be manipulated from R in the usual way: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I think about it the more I feel this would be better done with a helper ctor that would support both shapes of data frames and would check for data frame invariants on the JS side. Especially since this ctor downgrades to lists silently. It seems to me that the ease of use of this syntax is not worth the very real downsides on programming errors. We are compounding silent coercions and laziness of checking (if any) here.
If this is just for debugging then this should probably not be documented prominently. But also I feel like a short-name ctor would be just as good for interactivity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in another forum, we'll keep this as-is for now, but address the issues in the next minor release of webR with the aim of stabilising the mapping between JS object shape and R object type.
My current plan is the following changes:
- Reserve this JS syntax for constructing only
data.frame
s when using the genericRObject()
constructor. - Remove the list fallback and throw an Error instead. R lists can still be constructed using e.g.
RList()
. - Add a small
RList
subclass,RDataFrame
, for explicitdata.frame
construction. - Document the above, recommending for production code to use the explicit constructors rather than
RObject
.
We'll continue this discussion in a future PR on the webR repo.
Co-authored-by: Lionel Henry <[email protected]>
Thanks again for the proof read and review! |
To be posted after webR 0.3.0 hits npm and CDN.
Indended to expand on some of the items in webR's
NEWS.md
file. The post is perhaps a little heavy on details aimed at JavaScript developers, but hopefully still interesting to the general audience.Some of the example output is hard-coded in the source, rather than generated by
knitr
, e.g. JS output and errors. There is some custom styling near the start of the post to tweak the visuals for this.Includes updates to the version of webR itself shipped on the website - used for interactive examples.
Updated links to hotfix 0.3.1 release.