Thursday, January 10, 2019

Apparently, Failure is an Option

At one point last year, I noted in awe that Andrew Gelman's blog had entries scheduled for publication months in advance. I stated that my criteria for success would be a much more modest "at least one post within the past two weeks" (or something similar).

I guess even that was being optimistic.

I won't make any grand New Year's resolutions about posting frequency, but I do hope to be a little more consistent this time around.

Happy New Year!

Wednesday, December 12, 2018

Rendering bupaR Process Maps in RMarkdown PDF

I've been playing around with a very nice R package called bupaR, which stands for "Business Process Analysis in R." It is actually a suite of packages that support different parts of the process mining workflow.  For those unfamiliar with the term, process mining is a method of extracting information from event logs. It is a type of data mining, but with a temporal aspect as information moves through a business process (think: booking a flight, approving a purchase order, etc.)

In my case, I was trying to do some process mining on IT help desk-type ticketing system. Because this was some initial exploration, I was using RStudio to create and RMarkdown document in which I could keep track of what I was doing and present some output from the analysis.

The bupaR ecosystem has a package called processmappeR which can create process maps (kind of like a flow chart) from an event log. When knitting the document to HTML, the maps were coming out beautifully, as were the various other figures I was generating. However, when I tried to knit to PDF to share the document with a colleague, I noticed that all of the process maps were missing without a trace.

Long story short, the processmappeR package seems to rely on network graph diagrams that were intended for use in a viewer or Shiny app. After lots of Googling, I came across a thread in the DiagrammeR GitHub repository that had an answer and a link to a more complete discussion by Yihui, the creator of bookdown (https://bookdown.org/yihui/bookdown/html-widgets.html).

The basic idea is to install the webshot package, then use that package to install phantomJS.

install.packages("webshot")
webshot::install_phantomjs()

This essentially takes a screen shot of the graphic that you are trying to render as part of the knitting process. I'm still working on tweaking the resulting images, but the process worked like magic and I now have all of my process maps as part of my PDF document. Awesome!

Thursday, November 22, 2018

DC is Where We R

A couple of weeks ago, I attended the DCR conference. It was a great experience, and it was fascinating to see all of the ways in which R is used by folks in a variety of organizations. I was particularly happy to see that the conference organizers made a conscious effort to have a robust female representation in terms of presenters. 

Given that we are in the DC region, we were treated to a talk about the creation of the MNIST data set by someone from NIST. Anyone who has ever taken a course in machine learning is probably familiar with MNIST's "hello world" status in that field. 

I'm looking forward to attending DCR in the future.

Wednesday, October 31, 2018

Mile High

I realize that I have been a little remiss in blogging recently. (I'm not too worried, as I have no intention of becoming a professional, or even serious amateur "blogger".) I'm currently in the Mile High City of Denver, Colorado to attend EDUCAUSE 2018.

This is my first time at EDUCAUSE, and so far I am enjoying myself.  Yesterday,  I attended an interesting pre-conference workshop on scaling up learning analytics. Today the conference begins in earnest, and I hope to see lots of useful presentations. I'll also get a chance to get a better sense of the scale of the conference. I attended and ACTFL conference many years ago in Denver, so we'll see how the size compares to this conference.

Friday, October 5, 2018

Some Things Never Change

I came across the following passage while reading H.G. Wells' story "The Food of the Gods and How It Came to Earth". Even though the story was first published in 1904, this description of the simultaneous lack of teaching skills but extreme confidence in one's instructional methods made me smile:
I heard Bensington also once—in the old days—at an educational conference in Bloomsbury. Like most eminent chemists and botanists, Mr. Bensington was very authoritative upon teaching—though I am certain he would have been scared out of his wits by an average Board School class in half-an-hour—and so far as I can remember now, he was propounding an improvement of Professor Armstrong's Heuristic method, whereby at the cost of three or four hundred pounds' worth of apparatus, a total neglect of all other studies and the undivided attention of a teacher of exceptional gifts, an average child might with a peculiar sort of thumby thoroughness learn in the course of ten or twelve years almost as much chemistry as one could get in one of those objectionable shilling text-books that were then so common...
I imagine we still have many such folks among us. 

Saturday, September 22, 2018

The Path to Graduate Assistant

When I was a graduate student, the department tried to find Graduate Assistant positions for as many students as possible. The department was relatively small and oversaw two ESL programs, which were staffed primarily by students. Although not all students would get a position, most of us would have at least a half-time (.25FTE) opportunity either teaching, doing research, or doing administrative tasks in one of the centers that the department oversaw.

I don't recall any strict application process to become a GA, though I think we had to submit a form that indicated that we were interested in a GAship. Sometime before the start of the semester, the department chair would get in touch and say "I think we can give a position teaching X? Is that OK with you?".

Fast forward several decades. I've just been through the process to hire a GA to work with me. After posting the position, I was expecting a handful of applicants during the week long application window, and was shocked with how many applications came in -- the final count was over 50.

Not only were there many more applicants than I had anticipated, most of the applicants had very impressive resumes. Selecting candidates to interview was not an easy task, and even during the interviews I could imagine each of the candidates contributing positively to the team.

In the end, I chose the person I thought would best be able to hit the ground running with what we needed.

The whole process made me reflect on the norm-referenced nature of these decisions. As an applicant, your fate is dependent not only on the quality of your background but also on the background of the other applicants in the pool. The same resume can be "strong" in one context and "average" in a different context. Had any of the applicants been the only person in the pool, they probably would have been hired (and probably would have been able to do a good job).

Thursday, September 6, 2018

Squish

I came across a very useful R function the other day called squish. It is available through the scales package (which installed with ggplot2 -- part of the tidyverse).

The purpose of squish, according to the documentation, is very simple: "squish values into range."  This turns out to be incredibly useful in some situations.

Suppose that you are looking at data from on online course that describes the number of pages views for each module for each student (for our illustration, we'll assume 10 students and four modules, A, B, C, and D) :


Further imagine that there is one student who, for whatever reason, happened to have a huge number of page views for one of the modules. In other words, there is an outlier in one of the cells.


The challenge comes when you want to visualize the relative difference between students across the four modules. The presence of the outlier makes a heatmap-type visualization almost useless:

library(ggplot2)
data %>% ggplot(aes(x=Module, y=as.factor(Student))) +
  ylab("Student") +
  xlab("Module") +
  geom_tile(aes(fill=Views)) +
  scale_fill_gradient(low="green", high="blue") +
  ggtitle("Page views per module by student")





This is where squish comes in. Instead of using the actual range of 1 view to 168 views to determine the colors, we can "squish" the range to be, say, 1 to 12. Anything over 12 will be "squished" into the range (i.e., treated as 12). By simply importing the scales library, setting out desired scale limits, and calling the squish function for the "out of bounds" (oob) argument, we now have a much better visualization:

library(ggplot2)
library(scales)
data %>% ggplot(aes(x=Module, y=as.factor(Student))) +
  ylab("Student") +
  xlab("Module") +
  geom_tile(aes(fill=Views)) +
  scale_fill_gradient(low="green", high="blue", breaks=waiver(), limits=c(1,12), oob=squish) +
  ggtitle("Page views per module by student")




Whether it is appropriate to squish your values depends on the context of your investigation. But if you need to, squish makes it easy to do so.