week 3

Using the TableOne package for the Paper 1 dataset.

Bonnie Butler true
2021-03-07

I have been tackling the Paper 1 dataset using the TableOne package. I hadn’t used TableOne before, so I first followed the instructions using the dataset from “Introduction to tableone” (https://cran.r-project.org/web/packages/tableone/vignettes/introduction.html).

I then applied the same instructions to the palmerpenguins dataset (https://allisonhorst.github.io/palmerpenguins/).

When I felt comfortable using the package, I then turned to the dataset for Paper 1. I was able to easily replicate the mean and SD columns from Table 1, but there is no function in TableOne for range.

I trawled the web searching for some kind of solution or work around. One PDF for the TableOne package (https://cran.r-project.org/web/packages/tableone/tableone.pdf) indicated that “The minMax argument toggles whether to show median [range]”. I had hoped this would give the minimum and maximum values for each, which may have been the best case scenario, but this was not the case.

I finally stumbled upon the rndr (render) function that can be used for TableOne to display different statistics for different variables (https://cran.r-project.org/web/packages/table1/vignettes/table1-examples.html). It appears as though you can request that the minimum and maximum values are calculated for specific variables, although I can’t see an option to do this for all (and therefore not have to enter multiple lines of code requesting minimum and maximum values for each variable).

My first task for Week 4 will be to play around with the rndr function. Failing that, I will try to find a package that produces a similar table to TableOne, but includes mean, SD and range.