petermeissner

R Internet: Yet Another Way To Send Emails On Windows

Intro

Using email to send notifications seems old school nowadays. Quite often its nonetheless a tool that is available and accepted in many settings and where recipients are already familiar using it.

While sending emails from Linux machines is quite easy, sending them from Windows always has been is a little bit tricky. Windows neither ships with with SMTP servers (Simple Mail Transfer Protocol) nor has it a tradition of using package managers for easily and reliably installing additional software and services.

There are several solutions to to sending emails on Windows. Most of them involve connecting to a remote SMTP server or API some others wrap around dedicated programs like e.g. blat. This blog post on mailtrap.io lists a lot of possibilities (also here, and here).

R treasures: modifyList()

Sometimes, more precisely quite often, the standard libraries hold treasures that we are not aware of. Maybe they have obscure names, have been reinvented and shadowed by the newest cutting edge convenience package or one simply does not expect those treasures to be there so they are hidden in plain sight.

The modifyList() function is one of those treasures. Its part of the {utils} packages so it ships with every R version ready to use without further dependencies.

The function offers a way to merge two lists into one similar to c(), the concatenate function. But other than with using c() items with the same keys will be updated instead of simply added. Thus modifyList() presents the answer to the question:

In R, how to update items of a list with the values of another list?

Tuning the IPython Terminal Prompts

The problem

I like the IPython terminal for all its colors and syntax completion but what I really cannot stand is getting told all the time that this line is an input and the other one right after is an output.

Why?
Its an interactive terminal.
I know that the one line is the input and the other line right after is the output.
I just typed those lines in.

Enough ranting IPython has been around for some time now and would not have gotten its superp reputation and wide spread acceptance if there was not a tweak to be made.

Python Multi File Modules

The problem

The basic problem obviously is that I have a very distinct and opinionated way to think about modules and Python’s own opinion doesn’t make it easy to get it done the way I think is best.

Installation of NodeJS on RaspberryPi - Keep it Simple

Googling for “install nodejs raspi” I get millions of blog post telling me how to best install NodeJS on a RaspberryPi. Well and this is yet another.

The blog posts often explain how to get the newest version and results range from proposing version 6.x.x up to version 12.x.x as newest - some using a browser, some using the command line interface.

I think: Its all to complicated. Raspian already comes with a NodeJS version available via package manager. So, my humble advise to future me and to all those tinkerers big and small: Go tinker some more and use whichever NodeJS version is available via apt.

sudo apt update
sudo apt upgrade
sudo apt install nodejs -y
node -v
## v10.15.2

Wikipedia Page View Statistics Late 2007 and Beyond

The {wikipediatrend} package

Simple Tabulations Made Simple

The {tabit} package

Using httr to Detect HTTP(s) Redirects

The Summary

In this short note I will write about the httr package and my need to detect whether or not an HTTP request had been redirected or not - it turns out this is quite easy. Along the way I will also show how to access information of an HTTP-conversation other than the actual content to be retrieved.

Re-exporting the magrittr pipe operator

… or how I stoped worrying and wrote a blog post to remember it ad infinitum.

Magrittr’s pipe operator is one of those newish R-universe features that I really want to have around whenever I put some lines into an R-console. This is even TRUE when writing a package.

So the first thing I do is put magrittr into the DESCRIPTION file and add an __imports.R file to the packages R/-directory with the following lines:

#' re-export magrittr pipe operator
#'
#' @importFrom magrittr %>%
#' @name %>%
#' @rdname pipe
#' @export
NULL

These lines import and re-export the pipe operator (%>%) therewith allowing to use it within my package but also beeing able to use it interactively whenever the package is loaded.

Best of all these lines will also ensure passing all package checks (CRAN complient) and preventing any “The following objects are masked from …” messages.

Last but not least the file name “__imports.R” serves two purposes (1) making the it appear at the very beginning of an alphabetical sorted lists of file names and (2) second giving it a speaking name to inform - however reads the file name - that some R “Imports” are most likely happening inside.

Happy coding!

PS.: Those lines above require the usage of roxygen2 as documentation framework.

Robotstxt Update - v0.6.0 on CRAN

I just got the news from the CRAN-team that the robotstxt version update 0.6.0 was accepted and now is available.

The robotstxt package aims at working with robots.txt files from within R by providing a parser as well as a permission checker - and some convenience goodies working behind the scenes.

This new version switches the default checking backend from an pure R implementation (done by myself) to a C++ implementation (done by Moz and wrapped by Bob Rudis) that is both executing much faster and also much more rigourous in interpreting the the standard (RFC). While it was hard to throw away so much of my own work it also is very liberating to now have to maintain lesser code and leaving the package with the feeling that it now is in a better state (more robust) than before.

Thanks CRAN, thanks Bob, thanks Moz.