R | Jason Bryer


How Long Does it Take to Win War?

My son has been learning Python and wanted to know how many rounds does it take, on average, for someone to win the game of war. If you are not familar with the game, it is a two player game where each player gets half a deck of cards (26). For each round the player puts down their top card. Whoever has the higher card gets both cards. In the instance where there is a tie, each player puts down three more cards and flips the fourth card.

Using Shiny to Create an Academic Poster

TL;DR Run shiny::runGitHub(‘jbryer/ShinyPoster’) see an example poster. Go to https://github.com/jbryer/ShinyPoster to download the template Introduction In the past several years academic conferences have begun to display poster presentations electronically. This provides an opportunity for authors to include interactivity into their posters. Shiny has become a popular and powerful framework for researchers to create interactive web applications. This poster and paper presents a framework for creating traditional two or three column posters using Shiny.

SFTP in R on a Mac

I am working on a project where I need to upload PDFs generated from Rmarkdown to a SFTP server. The sftp R package is a nice wrapper to the RCurl package for handling SFTP access. But to my surprise, SFTP support is not included on Macs by default through the curl command. After some research I found the curl-openssl formula that includes SFTP support. However, since curl is a build-in program for Mac OS brew install will not install it into the PATH environment, therefore not being directly available.

Map my run in R

First, I want to give a plug to the RStats Strava Running Club. If you are into running, it is a great group that provides lots of support. This post is inspired by this streetmaps tutorial over at ggplot2tutor.com on creating map artwork/posters. This post shows how to overlay running (which could be biking) routes. The key for this to work is to get access to GPX (GPS Exchange format) files.

Framework for Shiny Apps in R Packages

TL;DR: You can test this approach using this Github Gist. R Shiny Apps have become a popular way of creating web applications in R. There are many ways of running Shiny Apps including locally in RStudio, on Shinyapps.io or installing the server software on your own host. I have been increasingly using Shiny apps as a way to demonstrate and interact with R Packages, especially packages I write for teaching purposes.

Editable DataTables for Shiny Applications

RStudio recently updated Shiny to allow for editable DataTables. Their implementations allows for editing cells direclty with in the DataTable view. This is fine for many advanced applications, however, for many applications more fine tuned control of what the user can edit is necessary. For example, you may want to only allow a subset of columns to be editable. Or you want to view a subset of columns in a spreadsheet view but allow other columns to be editable.

Conducting Assessments and Surveys with Shiny

This post describes a framework for using Shiny for conducting, grading, and providing feedback for assessments. This framework supports any multiple choice format including multiple choice tests or Likert type surveys. A demo is available at jbryer.shinyapps.io/ShinyAssessmentTest or can be run locally as a Github Gist: runGist(‘a6fb5a3b1d5fd56cff64’) Key features of this framework include: Assessments take over the entire user interface for a distraction free assessment. Creating an assessment requires: A vector of item stems.

Shiny App for Bayes Billiards Problem

Consider a pool table of length one. An 8-ball is thrown such that the likelihood of its stopping point is uniform across the entire table (i.e. the table is perfectly level). The location of the 8-ball is recorded, but not known to the observer. Subsequent balls are thrown one at a time and all that is reported is whether the ball stopped to the left or right of the 8-ball. Given only this information, what is the position of the 8-ball?

Data Caching

Data caching is not new. It is often necessary to save intermediate data files when the process of loading and/or manipulating data takes a considerable amount of time. This problem is further complicated when working with dynamic data that changes regularly. In these situations it often sufficient to use data that is current with in some time frame (e.g. hourly, daily, weekly, monthly). One solution is to use a time-based job scheduler such as cron.

Women Graduates in Math, Statistics, and Computer Information Systems

One of the more interesting talks at this year’s useR! Conference was the heR Panel discussing the role of women in the R community. They estimate that fewer than 15% of package authors are women. One of the points brought up was that this is less than the percentage of women in statistics. Perhaps this is more related to the computer science aspect of R that that of statistics. By way of comparison, the United States Department of Labor estimates there are between 7.