Let’s imagine a situation. You generate some number(s) in R or Python or whatever and want to include these numbers in a LaTeX document. Most people (I assume) just copy/paste the numbers from the console to the document.1 This means that if you update the analysis, your document may be reporting incorrect information.
There are some solutions to this, of course. One solution is to mix the code together with the document (rmarkdown users will be familiar with this).
Last week I taught a quick workshop on R.
It includes the basics of working in “package-less” R: data types, loops, the “apply” family, etc.
PDF slides and html content for easy copy/paste are available here.
Introduction to Math for Political Scientists, AKA “Math Camp,” starts on Monday. The class is an absolute blast to teach, but that’s not the subject of the post. I’ve made the slides for the course in rmarkdown because I mix math and R code together.1 I can then export them fairly easily to pdf slides via the rmarkdown package, which relies on pandoc to convert the markdown to latex and then compile the latex.
I’ve always wanted one of those wall maps that you can push pins into to show where all you’ve been. However, with college and grad school and whatnot, I’ve never really had the energy to put one up, since I know I’ll just have to take it down the next time I move. Then, something occurred to me:
I like maps. I like traveling. I like R. So why not spend a night putting them all together?
Lots of little things happen in grad school that take you by surprise but really shouldn’t. One of those things for me happened after I finished all of my coursework. Without the deadlines of weekly seminars, I didn’t read journal articles or books nearly as often as I should have. I figured this out about this time last year and made it my New Year’s resolution to get better at keeping up with journals.
I submitted final course grades today. The semester is over, hurrah!
Of course, getting the grades out of my university’s learning management system (we use Canvas) was a pain. It exported to csv, but the first three rows contained some meta-information instead of students’ grades. And there were some rows that weren’t students. So this meant that when I imported this into R, all the columns in my data.frame were of type character instead of numeric:
This is a post in a series of posts about using pandoc to convert between markdown, latex, word, and pdf. It should stand on its own, but you may want to go though the posts sequentially.
Intro OK, you have installed pandoc to convert your markdown or latex file to docx and sent it off to your adviser for comments. Now they send that file back, with comments in the word document and changes made using Word’s “track changes” feature.
This is a post in a series of posts about using pandoc to convert between r/markdown, latex, word, and pdf. It should stand on its own, but you may want to go though the posts sequentially.
Even though word processors are stupid, MS Word’s ubiquity means that occasionally I have to convert a latex or markdown document to a docx file for a colleague who insists on using Word’s “comments” feature or for submission to a journal that doesn’t accept pdfs (though thankfully, the vast majority do today).
I’m all the time asked something along the lines of “Hey, you taught me markdown/latex, but my adviser wants to give me comments in Word. How can I make that happen?”
The answer, unfortunately, is a little complicated. The best way to do this is to use pandoc, an absolutely wonderful program that converts between all kinds of markup formats (including between markdown, latex, and docx documents).1 Pandoc is very powerful, but a little overwhelming, especially if you aren’t used to working with command line applications.