Have you ever been stuck watching or just waiting for your code to finish? This post will outline a simple example program that you can use to email a file or message. I've found this incredibly helpful on time critical projects where I want to maximize my time by coding up the next problem while the current one executes. The mailR package allows you to programmatically attach files and email results to yourself. Assuming your company SMTP server is open for you to use, the mailR package can support you in doing this. My example below emails the R script used to create the email to myself. I'm hoping that I can send an example of a rmarkdown file as the body of the email in my next example using this package.
Tuesday, December 8, 2015
Tuesday, November 10, 2015
Package of the Month: DT
Sometimes you have the need to email someone a dataset for them to analyze. In the past, I always sent an Excel workbook with a bit of formatting. This always takes a bit of time, and never looks as pretty as you want it to. Plus, Excel workbooks just don't work well on cell phones. I've found a nice package that is a wrapper for the DataTables plug-in for jQuery. This package allows me to email out a html file for people to review and analyze as they see fit. Below are just a sample of options I've found handy.
First, let's load in some data and view the default look of the table.
By default, we can search the table and sort individual columns. Let's change the page length to 20 and remove row names.
Sometimes you want to set the default sort order. Here we sort the table by weight descending.
One really cool extension for DataTables allows you to drag and drop columns into a custom order as you explore the data. Combine this with the ability to hide columns really helps you customize a look for the table.
Finally, let's combine all of these tables and save it to an html file to email out.
Note, to get this to look somewhat nice on my blog, I automatically hide several columns.
First, let's load in some data and view the default look of the table.
By default, we can search the table and sort individual columns. Let's change the page length to 20 and remove row names.
Sometimes you want to set the default sort order. Here we sort the table by weight descending.
One really cool extension for DataTables allows you to drag and drop columns into a custom order as you explore the data. Combine this with the ability to hide columns really helps you customize a look for the table.
Finally, let's combine all of these tables and save it to an html file to email out.
Note, to get this to look somewhat nice on my blog, I automatically hide several columns.
Subscribe to:
Comments (Atom)