Using RStudio for APA Style and More

ProfHacker 2018-05-14

RStudio isn’t new to the ProfHacker readership. In fact, the other Ryan (the original Ryan, really) wrote on using it and is 100% the inspiration for this post.

See, I like Shiny new things (that’s an in-joke joke for the R crowd). I can’t help it. I also like forward movement at the risk of failure (I think they call it “innovation” but I could just be rationalizing). So when I first ran across Markdown, I was a bit taken aback. “This seems regressive,” I thought, in an utterly knee-jerk reaction. It didn’t look like futureproofing to me; it looked like a return to earlier, simpler times.

And that’s true, it is. Just not in the way I initially thought. Instead of going backwards, it’s a return to a certain kind of platform agnosticism. It’s a means of writing that sheds the accoutrements and trappings of the proprietary, WYSIWYG Word Processor in favor of pure content. Those of you that have used it are probably smirking and thinking, “Well, yeah, that’s the point.” It took me a while to understand that. Hopefully this will sway others that are still either on the fence or just don’t know enough about it yet, as I was when I was first introduced.

First, Markdown. Simply put, it’s a markup language: HTML stands for hypertext markup language; Markdown is similar in that it uses symbols to denote format, syntax, et cetera. The difference is one of usability, in the end. When writing HTML, to format text you’d use CSS, either in an external style sheet or directly in the document, using tags like <span> and <div> and styles like text-decoration. To achieve the same in Markdown you’d surround text with astrixes or underscores to make text bold and italic, respectively. (You can read a lot more about Markdown in the ProfHacker archives!) This produces clean code you can copy and paste nearly anywhere. By “knitting” RMarkdown files in RStudio (“knit” is RStudio terminology for “compile,” basically) you can easily choose HTML files, PDFs, Word documents, pretty much anything you want. Throw Pandoc in the mix and the options are endless. Here’s a screenshot of this actual post from RStudio, where I drafted it:

Rstudio

Next, R. R is statistical computing software, similar to SAS and SPSS. And while R is the core of RStudio, it’s not really the focus of my content here. I’m more interested in what RStudio can produce in terms of what I write, not what I can code and analyze. One thing at a time.

I have been very happy with my RStudio-built-and-knitted curriculum vitae that Ryan explained (just being able to point people to the CV and then knit a PDF that uses the same content and looks fantastic is… well, fantastic). I’ve tried using it to build class websites and whatnot but as we’ve already got a departmental ecosystem in place for this sort of content, it’s fairly superfluous for me. Then I started thinking, “Hm, I wonder if I can get RStudio to produce a perfectly formatted APA paper with references.”

Lo and behold, it can. I discovered an RStudio add-in called papaja. The acronym stands for “Preparing APA Journal Articles,” unsurprisingly. The instructions on the GitHub readme are pretty straight forward, so I won’t repeat them here, other than to say it took me a little fiddling to get everything to work smoothly, mostly because I wasn’t following the instructions to the letter. So, some advice: follow the instructions to the letter, even with the naming of files, at least until you get it working and want to customize it to your liking.

Not only does papaja create APA papers with proper fonts, spacing, et cetera, but even formats your nifty R charts and tables properly. Being able to ignore the trappings of style while producing content is incredibly powerful, making this a worthwhile project to get set up over the summer.

As a bonus, if you want to play around with other styles, RStudio has an Edward Tufte-style document template to play with and it is really fun.

So, if you’re like I was and haven’t had a chance to start playing with RStudio, add it to your summer to-do list. This is really just scratching the absolute surface of what it can do but the APA formatting template alone is worth the time, I think. Oh, and if you’re a Windows user and having difficulty with installing or updating packages, just make sure to run it as an administrator.

What about you? Are you a Markdown or RStudio convert? Know of any add-in gems to share? Do so in the comments!

Image from Unsplash user Patrick Fore used with CC0 license.