R packages

The Gmisc and Greg package contain useful functions for graphics, tables etc that I’ve created/adapted for my own research. Gmisc was published on CRAN 2014-02-02. As some of the regression functions weren’t stable enough for going public I’ve moved these into the new Greg-package.

As CRAN limits the update frequency to 1-2 months you can download the most recent package from GitHub. The Greg package will hopefully reach maturity spring 2014 but until then you can download them using the devtools package:

?View Code RSPLUS
1
2
3
4
5
6
7
8
9
10
# If you haven't installed devtools before, 
# now is the time by uncommenting next line:
# install.packages("devtools")
 
# Install the Gmisc package using:
devtools::install_github("gforge/Gmisc")
 
# After installing the Gmisc package 
# you can install the Greg package using:
devtools::install_github("gforge/Greg")

Writing documentation is hard and any suggestions are greatly appreciated. Try also to check that the output makes sense as bug-hunting is a difficult and endless task. If you want to suggest some changes, please use the GitHub-version as it has all the roxygen documentation and all my comments.

Some of the neat Gmisc functions that you will find are:

  • forestplot2 – an adaptation of the rmeta package forestplot with some additional tweaks
  • htmlTable (see also examples here) – it is often difficult to convert LaTeX into word without some loss to design, therefore I’ve created an alternativ to the Hmisc latex() function with basically the same parameters and output but that works in markdown. You can now simply copy-paste the table into Word.
  • getDescriptionsStatsBy – for generating a table 1 this is a very useful function that makes this much easier.
  • transitionPlot – for generating a transition plot
  • bezierArrowSmpl/bezierArrowSmplGradient – nicer alternatives to the default bezier arrow.

And the Greg-package contains among other things:

  • printCrudeAndAdjusted – a useful function for generating a table with a models crude and adjusted estimates.
  • plotHR – this is based upon r-forge Reinhard Seifert’s plotHR function. The function allows multiple models to be plotted on top of eachother, when used together with transparency (the alpha channel of the rgb) it is very convenient for comparing different subgroups, time-spans or adjusted/unadjusted regressions.

I hope you find the packages as useful as I do. And in case you were wondering – Yes, the Gmisc name is a ripoff from Frank Harrell’s useful Hmisc-package.

Max

flattr this!

6 Responses to R packages

  1. Fr. says:

    Unfortunately, the current installation code does fail on Macs: here’s its output on R 3.0.0.

    • Max Gordon says:

      Hmm… seems to be some issue with the rms-package. Have you tried installing without the dependencies?

      • Fr. says:

        It works if you install “rms” separately:

        install.packages("rms")
        reps = c("http://ftp.sunet.se/pub/lang/CRAN",
                 "http://cran.gforge.se")
        install.packages("Gmisc", repos = reps, dependencies = FALSE, type = "source")

  2. Pingback: Some Results | Shige's Results

  3. Peter says:

    Hi,

    I am currently playing around with your transition plots and I like it very much.

    Features missing I think are options for setting headers and subtitles as well as enabling the user to give all boxes individual texts. I tried the latter in order to also give an information about reaction times in a pre-post-measurement design, but now I get the error:

    Error: could not find function “getGridVal”

    while I have a help file available on that function, it is neither in my workspace after loading Gmisc, nor can I find in your Gmisc github repository.

    What happended here?

    • Max Gordon says:

      The latest version allows for creating your own layout around the plot, just push a grid viewport(), plot using the newpage=FALSE into that viewport. Also, see if you still get the error after setting the newpage=TRUE – there may be some old plot info that causes issues. I’m planning on adding the header option, unfortunately I haven’t had time to implement it yet but you can have a look at the forestplot2() that has the header option working in a similar fashion.

      You can put any text you want in your boxes, I’m currently writing an article on Charnley classification A, B and C before and one year after surgery. In the transitionPlot() call I simply have:

      box_txt=cbind(c("Charnley\nclass\nA", "B", "C\nPre-op."), c("Charnley\nclass\nA", "B", "C\nPost-op."))

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>