Monthly Archives: August 2012

Addendum to yesterday’s post on custom CSS and R Markdown


Updates from RStudio support:
(1) “Thanks for reporting and I was able to reproduce this as well. I’ve filed a bug and we’ll take a look.”
(2) Taking a further look, this is actually a bug in the Markdown package and we’ve asked the maintainer (Jeffrey Horner) to look into it.

As juejung points out in a comment on my previous post, applying custom CSS to R Markdown by sourcing the custom rendering function breaks the rendering of inline equations.

I’ve opened an issue with RStudio support and will update here with their response. In the meantime, one solution to this problem is:

  1. Do not create the files custom.css or style.R, as described yesterday
  2. Instead, just put the custom CSS at the top of your R Markdown file using style tags, as shown below
<style type="text/css">
table {
   max-width: 95%;
   border: 1px solid #ccc;
}

th {
  background-color: #000000;
  color: #ffffff;
}

td {
  background-color: #dcdcdc;
}
</style>

Custom CSS for HTML generated using RStudio

People have been telling me for a while that the latest version of RStudio, the IDE for R, is a great way to generate reports. I finally got around to trying it out and for once, the hype is justified. Start with this excellent tutorial from Jeremy Anglim.

Briefly: the process is not so different to Sweave, except that (1) instead of embedding R code in LaTeX, we embed R code in a document written using R Markdown; (2) instead of Sweave, we use the knitr package; (3) the focus is on generating HTML documents for publishing to the Web (see e.g. RPubs), although knitr can also generate PDF documents, just like Sweave.

It took me a little while to figure out a couple of things. First, how best to generate HTML tables, ideally using the xtable package. Second, how to override the default RStudio/R Markdown style. I’ve documented those tasks in this post.
Read the rest…

Reproducibility: releasing code is just part of the solution

This week in Retraction Watch: Hypertension retracts paper over data glitch.

The retraction notice describes the “data glitch” in question (bold emphasis added by me):

…the authors discovered an error in the code for analyzing the data. The National Health and Nutrition
Examination Survey (NHANES) medication data file had multiple observations per participant and
was merged incorrectly with the demographic and other data files. Consequently, the sample size was
twice as large as it should have been (24989 instead of 10198). Therefore, the corrected estimates of
the total number of US adults with hypertension, uncontrolled hypertension, and so on, are significantly
different and the percentages are slightly different.

Let’s leave aside the observation that 24989 is not 2 x 10198. I tweeted:

Not that simple though, is it? Read on for the Twitter discussion.
Read the rest…

ISMB 2012 on Twitter: here today, gone tomorrow

In previous years, when FriendFeed was used as the micro-blogging platform for the annual ISMB meeting, I’ve written a post describing some statistical analysis of the conference coverage. Here’s my post from last year.

This year, it appears that the majority of the conference coverage happened at Twitter, using the #ISMB hashtag. Here’s what happened on July 18th when I used the R package twitteR to retrieve ISMB-related tweets for July 13/14:

library(twitteR)
ismb1 <- searchTwitter("#ISMB", since = "2012-07-13", until = "2012-07-14")
length(ismb1)
# [1] 383

383 tweets. Here’s what happened when I ran the same query today:

library(twitteR)
ismb1 <- searchTwitter("#ISMB", since = "2012-07-13", until = "2012-07-14")
length(ismb1)
# [1] 0

Zero tweets. Indeed, run the same query via the Twitter web interface and you’ll see only a very few tweets with the message “Older Tweet results for #ismb are unavailable.”

So far as Twitter is concerned, ISMB 2012 never happened. Or if it did, the data are buried away in a data centre, inaccessible to the likes of you and I. Did you ever hear anything more about that plan to archive every Tweet at the Library of Congress? Neither did I. I very much doubt that it’s going to happen.

I think Twitter is great – for broadcasting short pieces of information, such as useful URLs, in near real-time. For conference coverage which benefits from threaded conversation, longer comments and archiving, I think it’s rubbish.

On July 18 I did manage to retrieve 3162 Tweets for ISMB 2012, created between July 13 and July 17. I’ll write about them in a forthcoming post. All I’ll say for now is – lucky I was able to grab them when I did.