prcr update

The R package for person-oriented analysis (prcr) is updated (it’s now version 0.1.4). In particular, it was not clear how to use the profile assignments (i.e., what cluster each response is in) in subsequent analyses. So, the update now returns two different representations of the profile assignments, or which profile is associated with each observation: …

More

Announcing clustRcompaR v.0.1.0

Announcing clustRcompaR v.0.1.0 Alex Lishinski and I worked on an R package over the last year or so. We are excited that it’s now available on CRAN. You can install the package using install.packages(‘clustRcompaR’) (only needed first time) and load it (more on its two functions below) using library(clustRcompaR). Here’s a description: Provides an interface …

More

MIP Models in R with OMPR

A number of R libraries now exist for formulating and solving various types of mathematical programs in R (or formulating them in R and solving them with external solvers). For a comprehensive listing, see the Optimization and Mathematical Programming task view on CRAN. I decided to experiment with Dirk Schumacher’s OMPR package for R. OMPR …

More

Formatting in a Shiny App

I’ve been updating a Shiny (web-based interactive R) application, during the course of which I needed to make a couple of cosmetic fixes. Both proved to be oddly difficult. Extensive use of Google (I think I melted one of their cloud servers) eventually turned up enough clues to get both done. I’m going to record …

More

Some R Resources

(Should I have spelled the last word in the title “ResouRces” or “resouRces”? The R community has a bit of a fascination about capitalizing the letter “r” as often as possible.) Anyway, getting down to business, I thought I’d post links to a few resources related to the R statistical language/system/ecology that I think may …

More

Accessing R Objects By Name

At a recent R user group meeting, the discussion at one point focused on two of the possibly lesser known (or lesser appreciated?) functions in the base package: get and assign. The former takes a string argument and fetches the object whose name is contained in the string. The latter does the opposite, assigning an …

More

Coin Flipping

I don’t recall the details, but in a group conversation recently someone brought up the fact that if you flip a fair coin repeatedly until you encounter a particular pattern, the expected number of tosses needed to get HH is greater than the expected number to get HT (H and T denoting head and tail …

More

Producing Reproducible R Code

A tip in the Google+ Statistics and R community led me to the reprex package for R. Quoting the author (Professor Jennifer Bryan, University of British Columbia), the purpose of reprex is to [r]ender reproducible example code to Markdown suitable for use in code-oriented websites, such as StackOverflow.com or GitHub. Much has been written about …

More

More Shiny Hacks

In a previous entry, I posted code for hack I came up with to add vertical scrolling to the sidebar of a web-based application I’m developing in Shiny (using shinydashboard). Since then, I’ve bumped into two more issues, leading to two more hacks that I’ll describe here. First, I should point out that I’m using …

More

Autocorrupt in R

You know that “autocomplete” feature on your smart phone or tablet that occasionally (or, in my case, frequently) turns into an “autocorrupt” feature? I just ran into it in an R script. I wrote a web-based application for a colleague that lets students upload data, run a regression, ponder various outputs and, if they wish, …

More

Shiny Hack: Vertical Scrollbar

I bumped into a scrolling issue while writing a web-based application in Shiny, using the shinydashboard package. Actually, there were two separate problems. The browser apparently cannot discern page height. In Firefox and Chrome, this resulted in vertical scrollbars that could scroll well beyond the bottom of a page. That’s mildly odd, but not a …

More

Alternative Versions of R

Fair warning: most of this post is specific to Linux users, and in fact to users of Debian-based distributions (e.g., Debian, Ubuntu or Mint). The first section, however, may be of interest to R users on any platform. An alternative to “official” R By “official” R, I mean the version of R issued by the …

More

Parsing Months in R

As part of a recent analytics project, I needed to convert strings containing (English) names of months to the corresponding cardinal values (1 for January, …, 12 for December). The strings came from a CSV file, and were translated by R to a factor when the file was read. The factor had more than 12 …

More

Learning R

I have recently dedicated myself to learning R, a programming language and environment for focusing largely on statistical analysis and computing. The benefit of using R over other statistical computing packages is that it is free, open-source, and has a hugely active community around its use.  R can be used cross-platform  (PCs, Macs, and Linux) …

More

Histogram Abuse

Consider the following Trellis display of histograms of a response variable (Z), conditioned on two factors (X,Y) that can each be low, medium or high: The combined sample size for the nine plots is 10,000 observations. Would you agree with the following assessments? Z seems to be normally distributed for medium values of either X …

More