Rython tips and tricks – Clipboard

For whatever reason, clipboard functionalities from Rython are under-utilized. One utility function for reversing backslashes is found here. This post demonstrates how you can use the clipboard to circumvent saving and loading files. It’s convenient for when you just want the quick insight or visual, rather than a full-blown replicable process.

Consider the following scenario: you come across a webpage containing a table, and would like to compute some basic statistics, or visualize a couple of columns from that table. A usual workflow for such a minuscule task is to (1) copy the table, (2) pasting it into Excel, (3) saving the Excel sheet, and (4) reading it into Rython.

Can we not just copy the table and read it directly from the clipboard? Yes we can!

Like so (click to play, and the Rython code below):


The code is below:

In R

In Python

Leave a Reply

Your email address will not be published. Required fields are marked *