Beautiful tables for linear model summaries #rstats. In this blog post I’d like to show some (old and) new features of the sjt.lm function from my sjPlot-package.
These functions are currently only implemented in the development snapshot on GitHub. A package update is planned to be submitted soon to CRAN. There are two new major features I added to this function: Comparing models with different predictors (e.g. stepwise regression) and automatic grouping of categorical predictors. There are examples below that demonstrate these features. The sjt.lm function prints results and summaries of linear models as HTML-table. Please note: The following tables may look a bit cluttered – this is because I just pasted the HTML-code created by knitr into this blog post, so style sheets may interfere. All following tables can be reproduced with the sjPlot package and the sample data set from this package. Linear model summaries as HTML table Before starting, sample data is loaded and sample models are fitted: SjPlot package and related online manuals updated #rstats # ggplot. My sjPlot package for data visualization has just been updated on CRAN.
I’ve added some features to existing function, which I want to introduce here. Plotting linear models So far, plotting model assumptions of linear models or plotting slopes for each estimate of linear models were spread over several functions. Now, these plot types have been integrated into the sjp.lm function, where you can select the plot type with the type parameter. SjPlot: New options for creating beautiful tables, documentation on #RPubs #rstats. SjPlot 1.3 available #rstats #sjPlot. I just submitted my package update (version 1.3) to CRAN.
The download is already available (currently source, binaries follow). While the last two updates included new functions for table outputs (see here and here for details on these functions), the current update mostly provides small helper functions. The focus of this update was to improve existing functions and make their handling easier and more comfortable. Automatic label detection One major feature is that many functions now automatically detect variables and value labels, if possible. But what are the exactly the benefits of this new feature?
Since version 1.3, you only need to write: Reliability check for index scores One new table output function included in this update is sjt.itemanalysis, which helps performing an item analysis on a scale or data frame if you want to develop index scores. The output of the computed PCA was suppressed by no.output=TRUE. The latest developer build can be found on github. Beautiful table outputs in R, part 2 #rstats #sjPlot. First of all, I’d like to thank my readers for the lots of feedback on my last post on beautiful outputs in R.
I tried to consider all suggestions, updated the existing table-output-functions and added some new ones, which will be described in this post. The updated package is already available on CRAN. This posting is divided in two major parts: the new functions are described, andthe new features of all table-output-functions are introduced (including knitr-integration and office-import) Simply creating various scatter plots with ggplot #rstats. Inspired by these two postings, I thought about including a function in my package for simply creating scatter plots.
In my package, there’s a function called sjp.scatter for creating scatter plots. To reproduce these examples, first load the package and then attach the sample data set: The simplest function call is by just providing two variables, one for the x- and one for the y-axis: which plots following graph: If you have continuous variables with a larger scale, you shouldn’t have problems with overplotting or overlaying dots. The same plot, when auto-jittering is turned off, would look like this: You can also add a grouping variable. If the groups are difficult to distinguish in a single plot area, the graph can be faceted by groups. Find a complete overview of the various function options in the package-help or at inside-r. Gefällt mir: Gefällt mir Lade... SjPlot. SjPlot has been released on CRAN!
You can install the package and its dependencies using install.packages("sjPlot")! Description Collection of several plotting and table output functions for data visualization. Results of several 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 (forest plots), PCA, correlations, cluster analyses, scatter plots etc.
Furthermore, this package contains some tools that are useful when carrying out data analysis or interpreting data (especially intended for people coming from SPSS and who are new to R). Beautiful output in R. Note: There’s a second part of this series here.
About one year ago, I seriously started migrating from SPSS to R. Though I’m still using SPSS (because I have to in some situations), I’m quite comfortable and happy with R now and learnt a lot in the past months. But since SPSS is still very wide spread in social sciences, I get asked every now and then, whether I really needed to learn R, because SPSS meets all my needs… Well, learning R had at least two major benefits for me: 1.) I could improve my statistical knowledge a lot, simply by using formulas, asking why certain R commands do not automatically give the same results like SPSS, reading R resources and papers etc. and 2.) the possibilities of data visualization are way better in R than in SPSS (though SPSS can do well as well…). Still, one thing I often miss in R is a beautiful output of simple statistics or maybe even advanced statistics.