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 only provides small helper functions as new 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. For instance, if you have imported a SPSS dataset (e.g. with the function
sji.SPSS), value labels are automatically attached to all variables of the data frame. With the
autoAttachVarLabels parameter set to
TRUE, even variable labels will be attached to the data frame after importing the SPSS data. If you have factors with specified factor levels, these will automatically be used as value labels. Furthermore, you can manually attach value and variable labels using the new function
But what are the exactly the benefits of this new feature? Let me give you an example. To plot a proportional table with axis and legend labels, prior to sjPlot 1.3 you needed following code:
data(efc) efc.val <- sji.getValueLabels(efc) efc.var <- sji.getVariableLabels(efc) sjp.xtab(efc$e16sex, efc$e42dep, axisLabels.x=efc.val[['e16sex']], legendTitle=efc.var['e42dep'], legendLabels=efc.val[['e42dep']])
Since version 1.3, you only need to write:
data(efc) sjp.xtab(efc$e16sex, efc$e42dep)
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 scales or index scores.
Let’s say you have several items and you want to compute a principal component analysis in order to identify different components that can be composed to an index score. In such cases, you might want to perform reliability and item discrimination tests. This is shown in the following example, which performs a PCA on the COPE-Index-scale, followed by a reliability analysis of each extracted “score”:
data(efc) df <- as.data.frame(efc[,c(start:end)]) colnames(df) <- sji.getVariableLabels(efc)[c language="(start:end)"][/c] factor.groups <- sjt.pca(df, no.output=TRUE)$factor.index sjt.itemanalysis(df, factor.groups)
The result is following table, where two components have been extracted via the PCA, and the variables belonging each component are treated as one “index score”:
Note that you don’t need to define groups, you can also treat a data frame as one single “index”.
Beside that, many functions – especially the table output functions – got new parameters to change the appearance of the output (amount of digits, including NA’s, additional information in tables etc.). Refer to the package news to get a complete overview of what was changed since the last version.
The latest developer build can be found on github.