Convince me to start using R Markdown

@markdly you can get the best of both worlds by using parameterized reports. You could write markdown like this:

---
output: html_document
params:
   cyl: 4
---

```{r}
df <- mtcars[mtcars$cyl == params$cyl, ]
df
```
4 Likes

My weekly battery of reports is a series of small summary tables with the transactional data summarized by various and a sundry categories.

Writing each table out as a csv separately in order to archive it accessibly isn't a terrible idea--experimenting with moving the formal report over to RMD with a csv archive sounds like a fun holiday break project!

1 Like

@crazybilly One particularly nice advantage of using readr::write_csv for writing out your data is that you can compress it just by providing a .csv.gz extension (and readr::read_csv can read it back in if it has that extension, too).

That does make inspecting the data from outside R a little trickier—something like gzip -cd blah.csv.gz | head has to replace head blah.csv if you're doing it from the shell—but it's great if you're writing out really, really big intermediate CSVs and don't wanna mess around with a binary storage format!

1 Like

Once I was reporting revenue numbers for a direct mail campaign. I reported one number, re ran the report, and got a number that was about 75% of the original revenue I reported.

Was not fun.

Decided that was the time to start making reproducible code. RMarkdown is great for sharing code, but honestly I love it because I can follow my own work more easily.

5 Likes

I had this same issue, as I produce tables in Excel, which were hard to replicate with conditional formatting from R. Have you looked into the officer package at all?

They use the flextable package, which seems far better than the formatting from knitr's kable. It's definitely hard to find a good table creation package.

I am trying to convince and organisation section to serious consider parmeterized reports as a solution to their problem-

They need to inform a bunch of groups about the groups relation to the overall total while keeping the individual details of the other groups confidential. They currently do this by preparing and sending out individual reports, and are thinking about moving to an elaborate database structure with login management where people see only there own things in order to cut the work of preparing individual reports.

I'm suggesting to them that a template parameterised report, with a control script having a render statement inside a sapply that sets the report pdf filename to the group and the parameterisation tells it which group to generate the individual results for inside the report, would cut the report generation work without adding all of the access management work (which they current do not have skills in)

1 Like

Hi, I too have been hovering on the verge of using RMarkdown.
One thing that has put me off is all the reference to LaTex; I have never used it and would struggle to get my employer to install it.

Is LaTex a requirement? How am I restricted if I don't have it? Do you have any good arguments I could use to support my case?

Thanks

darth you don't need a LaTeX distribution if you don't need to create PDFs locally.

If you really can't get LaTeX installed locally (it's not easy, but it's not much more onerous to install than R), you could use knitr to create a .tex file then use ShareLaTeX to create a PDF.

You can still knit to HTML without it, which goes a long ways these days. Yihui has recently assembled TinyTex, which is designed to make installing the necessary parts of TeX (without excess bloat) much easier, should you need to knit to PDF.

4 Likes

I switched to tinytex recently, and I'm really happy with it. Makes installing LaTeX as easy as installing an R package.

3 Likes

I finally did. I was worried uninstalling my current installation would be a pain, but since it was a homebrew installation, it wasn't actually too bad; just

$ brew cask uninstall basictex
$ sudo mv -v /usr/local/texlive ~/.Trash

was sufficient to allow the new installation. There are a lot of other artifacts lurking, though.

After installing TinyTeX, I relinked things to hopefully make most existing symlinks valid (not sure if anything points to them; maybe I should have deleted them all before reinstalling) and TeX Live Utility work again. I'm not sure I'll need it anymore—woo!—but the GUI has proved nice for figuring out what's going on with TeX packages.

Anyway, now the TinyTex is a svelte (by TeX standards) 178Mb, and I can knit PDFs, so I'm happy.

1 Like

@alistaire Yeah, I did a bit of Googling to ge trid of all those TeXLive artifacts. I don't think they do a whole heap of harm, though, as the tinytex installation seems to get everything with RMarkdown pointing the right way.

Thanks, TinyTex looks interesting. I'll give it a try.

It will be interesting to see whether installing it on R will enable me to bypass corporate restrictions on my work machine. I've not tried installing from GitHub on work machine.