sjPlot R-package

sjPlot-package

sjPlot is available on CRAN! You can install the package and its dependencies using install.packages("sjPlot")!

Description

Collection of plotting and table output functions for data visualization. Results of various statistical analyses (that are commonly used in social sciences) can be visualized using this package, including simple and cross tabulated frequencies, histograms, box plots, (generalized) linear models, mixed effects models, PCA and correlation matrices, cluster analyses, scatter plots, Likert scales, interpretation of interaction terms in regression models, constructing index or score variables and much more.

GitHub

You can download the latest development build from github.

Bug reports

Please submit bugs, issues and feature requests at github.

sjmisc-package

A package related to sjPlot is the sjmisc package, which is also
available on CRAN.
You can install the package and its dependencies with install.packages("sjmisc").

Description

This package contains some tools that are useful when carrying out data analysis or interpreting data
(especially intended for people coming from SPSS and/or who are new to R). These tool functions
support reading and writing data (SPSS, SAS and STATA), variable recoding and weighting, variable labeling,
statistical tests, reliability tests and much more.

GitHub

You can download the latest development build from github.

Bug reports

Please submit bugs, issues and feature requests at github.

Documentation

Basics of the sjPlot and sjmisc packages

Plotting functions

  • sjp.frq – plot frequencies of (count) variables
  • sjp.glm – plot odds ratios (forest plots) of generalized linear models
  • sjp.glmer – plot odds ratios (forest plots) of generalized linear mixed effects models
  • sjp.grpfrq – plot grouped or stacked frequencies
  • sjp.int – plot interaction effects of regression models
  • sjp.likert – plot Likert scales
  • sjp.lm – plot estimates of linear models
  • sjp.lmer – plot estimates (forest plots) of linear mixed effects models
  • sjp.pca – plot principal component analysis
  • sjp.scatter – plot (grouped) scatter plots
  • sjp.stackfrq – plot stacked proportional bars
  • sjp.xtab – plot contingency tables

Table functions

  • sjt.corr – correlations as HTML table
  • sjt.df – (description of) data frames as HTML table
  • sjt.frq – frequencies of (count) variables as HTML table
  • sjt.lm – linear models as HTML table
  • sjt.pca – principal component analysis as HTML table
  • sjt.stackfrq – stacked frequencies as HTML table
  • sjt.xtab – contingency tables as HTML table

 

Blog posts with examples of some functions

Note that, due to further development, some examples from the below listed blog posting might be out of date! Please refer to the package help (?sjp.-funcName-) for latest working examples!

sji.SPSS (Import SPSS dataset as data frame into R)

sji.viewSPSS (View imported SPSS datasets)

sjp.corr (Plot correlation matrix)

sjp.emm.int (Plot estimated marginal means of ANCOVA)

sjp.frq (Plot frequencies of (count) variables)

sjp.glm (Plot odds ratios (forest plots))

sjp.glmm (compare multiple models)

sjp.grpfrq (Plot grouped or stacked frequencies)

sjp.likert (Plot likert scales as centered stacked bars)

sjp.lm (Plot beta coefficients of lm)

sjp.lmint (Plot interaction terms of linear models)

sjp.pca (Plot PCA results)

sjp.scatter (Scatter plots)

sjp.stackfrq (Plot stacked proportional bars)

sjp.xtab (Plot proportional crosstables)

sjt.corr (Print correlation tabeles)

sjt.df (Description of data frames)

sjt.frq (Print frequency tables)

sjt.glm (Print odds Ratios as HTML-Table)

sjt.lm (Print linear models as HTML-Table)

sjt.pca (Print PCA as HTML-table)

sjt.stackfrq (Print stacked frequencies and Likert scales)

sjt.xtab (Print contingency tables)

31 Gedanken zu „sjPlot R-package

  1. Howdy Strenge Thanks for you great job!
    The horizontal borders in default are set as double lines in the output table. How can I change them into single lines, which are required by APA style.

    Thanks so much!

    Ryan

  2. That’s probably my favorite R package of the months, thanks a lot for this!
    Tables like this have been the only thing I missed in R, so I’m disturbingly excited about this.

    I hope you’ve gained enough support to improve and maintain the package, I’m hoping to recommend it to a whole bunch of people:)

  3. Daniel,
    Thank you so much for this package! I use it almost every day. It is wonderful. It makes my reports for behavioral health programs at San Francisco Department of Public Health beautiful and meaningful.

  4. Amazing package and exactly what I was looking for. Only issue I am having right now is that whenever I try to put sjt.frq into a knitr document, the resulting HTML document losses the formatting for the table. Any way to fix that?

    1. Currently, you can only plot in grey-scale, but not in b/w with different line types. However, I have thought about this option, too. This might be a feature for a next update.

      1. Hi Daniel, thanks so much for your efforts to develop all this! Your sjp.int function is super convenient and easy to use. That said, I would like to follow up on saalchris’s question whether it is possible (by now) in any way to have different linetypes instead of different colors for the various slopes. I would like to use the output for an article that will be printed in b/w and it is very hard to visually associate the slopes‘ colors with the legend, especially when confidence intervals are plotted, too. Thank you!

  5. Dear Daniel, I have to say thank you for your wonderful package. I was wondering if everything is alright with argumentation for plots. I am currently working on glm model and I wanted to add new labels to independent variables. I do the following:

    sjp.glm(model2, type = „prob“, show.se = TRUE,
    axisLabels.y = c(„Age“, „Education“), geom.colors=“ds“)

    Unfortunately, labels does not change as well as grey palette, which I specify with „gs“. I probably do something wrong. Could you please help me with that?

  6. Dear Daniel
    Thank you for this amazing package.
    I’m not sure if this is the right place for my question.
    I came across an issue with the odds ratio plot. I used it to plot the odds ratios for a logistic model with several continuous variables and several factor variable with more than two levels. In my model formula, they are mixed in the form:
    fit<-glm(y~factor1+continuous_var1+factor2+continuous_var2 and so on.
    When I call the sjp.glm(fit1) I get the odds ratio plot, but their are some weird odds included. Say, for example the factor 1 has the levels a, b, c. In the plot they are correctly listed, but additionally a new factor, which doesn't exist appears. To keep with the example, it would be named factor1a. Also, some actual existing variables are omitted in the plot. This doesn't happen, when I order the model in the form:
    fit<-glm(y~continuous_var1+continuous_var2+factor1+factor2 and so on.
    I just thought you might want to know this issue.
    Horst

  7. Hi
    I put together this little example. As i wrote it, I found out, that you don’t need more than one factor and continuous variable. The error occours with one of each, too.
    library(sjPlot)
    #generate data
    factor1<-rep(c("a","b","c", "d"),100)
    var1<-sample(50:60,400,replace=T)
    y<-sample(0:1,400,replace=T)
    data<-data.frame(cbind(y,factor1,var1))
    data$var1<-as.numeric(data$var1)
    #fit logistic model
    fit1<-glm(y~factor1+var1,family=binomial(link="logit"),data=data)
    fit2<-glm(y~var1+factor1,family=binomial(link="logit"),data=data)
    #plot model
    sjp.glm(fit1,sortOdds=F)
    sjp.glm(fit2,sortOdds=F)

    I hope it will help.
    Horst

Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s