The Gmisc package is a collection of different useful functions for graphics, tables etc that I’ve created/adapted for my own research.
To install use:
reps = c("http://ftp.sunet.se/pub/lang/CRAN",
"http://cran.gforge.se")
install.packages("Gmisc", repos=reps, dependencies=TRUE)
In case you’re using a Mac you need to install from source:
reps = c("http://ftp.sunet.se/pub/lang/CRAN",
"http://cran.gforge.se")
install.packages("Gmisc", repos=reps, dependencies=TRUE, type="source")
The main functions that I’ve created are:
- forestplot2 – an adaptation of the rmeta package forestplot with some additional tweaks
- 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.
- htmlTable – 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. I recommend opening the html-document in LibreOffice, and from there exporting to Word. This since Word does a very poor job at reading html formatting.
- printCrudeAndAdjusted – a useful function for generating a table with a models crude and adjusted estimates.
- getDescriptionsStatsBy – for generating a table 1 this is a very useful function that makes this much easier.
I hope you find the package as useful as I do. Once the package reaches the proper maturity I will try to publish it on CRAN.
/Max
Warning message:
package ‘Gmisc,repos=reps,dependencies=TRUE’ is not available (for R version 2.15.2)
Might want to look into that. Cheers.
Are you using Mac? In that case you need to add the type=”source”, I’ve added a “Mac-session”.
Unfortunately, the current installation code does fail on Macs: here’s its output on R 3.0.0.
Hmm… seems to be some issue with the rms-package. Have you tried installing without the dependencies?
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")
Hi,
I’m trying to use Gmisc to render frequency tables created with the table() function in knitr and right now I am getting no output.
Here’s some test markdown:
Frequency Tables
========================================================
This is an R Markdown document.
```{r results='hide',echo=FALSE,warning=FALSE,error=FALSE,message=FALSE}
library(Gmisc)
attach(cars)
```
This returns nothing:
```{r results='asis',warning=FALSE,error=FALSE,message=FALSE}
htmlTable(table(cars$dist))
```
But this shows some output:
```{r warning=FALSE,error=FALSE,message=FALSE}
table(cars$dist)
```
And of course, thank you for making this package available to all of us.
Cheers
The htmlTable expects a matrix with two dimensions, you’ve provided it a single dimension. I’ve updated the code so that it throws an error if the dim(x) != 2 as it is uncertain how to handle other dimensions.
If you still want to do your example then just do htmlTable(as.data.frame(x)) instead of your current call.
Thanks for the feedback!
When trying to install on windows, I get the message that Gmisc is not available for R3.0.0. Also, that it is available as a source package and not as a binary.
Can you suggest any workaround?
I’m going to add the 3.0 soon, try to install using the source option (the 2:nd alt.)