I’ve blogged about my in-development R package
hgr a before and it’s slowly getting to a CRAN release. There are two new features to it that are more useful in an interactive session than in a programmatic context. Since they build on each other, we’ll take them in order.
Objects created with
hgr::just_the_facts() used to be just
list objects. Technically they are still
list objects but they are also classed as
hgr objects. The main reason for this was to support the new default
hgr object, the new S3 method will extract the
$content part of the object and pass it through some
htmltools functions to display the readability-enhanced content in a browser (whatever R is configured to use for that on your system…you likely use RStudio if you read this blog and it will be in the Viewer pane for most users). This enables visual inspection of the content and (as previously stated) is pretty much only useful in an interactive context.
Rather than show you that now, we’ll see it in the context of the next feature.
‘Just The Facts’ RStudio Addin
I’m going to break with tradition and use a Medium post as an example, mostly because one of the things I detest about that content platform is just how little reading I can do on it (ironic since they touted things like typography when it launched). We’ll use this site as the example (an interesting JS article @timelyportfolio RT’d):
Now, that’s full-screen on a 13″ 2016 MacBook Pro and is pretty much useless. Now, I could (and, would normally) just use the Mercury Reader extension to strip away the cruft:
But, what if I wanted the content itself in R (for further processing) or didn’t feel like using (or policy disable the ability to use) a Chrome extension? Enter: “Just The Facts” RStudio Addin edition.
Just copy a text URL to the clipboard and choose the ‘Just The Facts’ addin:
and, you’ll get a few items as a result:
- code executed in your R console that will…
- add a new, unique object in your global environment with the results of a call to
hgr::just_the_facts()on the copied URL, and…
- the object auto-
print()ed in the console, which…
- displays the content in your RStudio Viewer
An image (or two) is definitely worth a 1,000 (ok, 48) words:
I’m likely going to crank out another addin that works more like a browser (with a URL bar in-Viewer) but also keep an in-environment log of requests so you can use or archive them afterwards.
Take it for a spin and don’t be sy in the GH issues page!
This is a Security Bloggers Network syndicated blog post authored by hrbrmstr. Read the original post at: rud.is