R is well suited for statistical graphics, the application of advanced
data analysis techniques, and Monte Carlo studies of estimators.
However, it lacks support for the typical data management tasks as they
arise in the social sciences as well as for the simple generation of
desctiptive statistics. “memisc” facilitates not only typical data
management tasks of survey researchers, but also the generation of
descriptive statistics, as they are often a first step in serious social
science data analysis. In particular it facilitates the creation of
tables of percentages of other descriptive statistics broken down by
subgroups in the data. This is mainly achieved by the function
genTable, which is described in the following section. The section
thereafter describes how tables thus created can be exported to LaTeX
and HTML.

General table of descriptive statistics can be created using the
function genTable(). The syntax of calls to this function is quite
similar to that of the function xtabs(): The first argument (tagged
formula) is a formula that determines the descriptive statistics
used and by what groups they are computed. The left-hand side of the
formula determines the statistics being computed. The right-hand side
determines the grouping factor(s). The second argument is an optional
data= argument that determines from which data frame or data set the
descriptive statistics are to be computed. This is illustrated by the
following example, which uses (like the page on item
objects) the GLES 2013 election study 1. In this
example we first create a table of some descriptives of the age
distribution of the respondents per German federal state:

(When the code is run, some warnings are issued, that indicate that the
conditions are not exhaustive, that is, there are some observations for
which none of the conditions in the call cases() are met. The
corresponding elements of resulting vector will contain NA for these
observations. In the present case this occurs with observations that
have missing values in both intent.turnout and turnout.)

It is of course also possible to create multi-dimensional tables, i.e.
tables created by grouping by more than one factor:

gles2013work<-within(gles2013work,{# We relabel the items, since they are originally in Germanlabels(turnout)<-c("Yes, voted"=1,"No, did not vote"=2)labels(gender)<-c("Male"=1,"Female"=2)})genTable(percent(turnout)~gender+bula,data=gles2013work)

The results of genTable() are objects of class "table" so that
they can be re-arranged into a “flattened” table by the function
ftable. To demonstrate this, we continue the previous example:

gt<-genTable(percent(turnout)~gender+bula,data=gles2013work)# We beautify the table a bit ...names(dimnames(gt))<-c("Voted","Gender","State")gt<-dimrename(gt,"Yes, voted"="Yes","No, did not vote"="No")ftable(gt,col.vars=c("Gender","Voted"))

Arranging the cells of a table using ftable() improves the
appearance of the results of genTable() on screen, but to include
the results into a word processor document or a LaTeX file, further
facilities are needed and provided by “memisc”. To include the flattened
table into a LaTeX document, one can convert and store it in the
appropriate format using toLatex() and writeLines()

The German Longitudinal Election Study is funded
by the German National Science Foundation (DFG) and carried out outin
close cooperation with the DGfW, German
Society for Electoral Studies. Principal investigators are Hans
Rattinger (University of Mannheim, until 2014), Sigrid Roßteutscher
(University of Frankfurt), Rüdiger Schmitt-Beck (University of
Mannheim), Harald Schoen (Mannheim Centre for European Social
Research, from 2015), Bernhard Weßels (Social Science Research Center
Berlin), and Christof Wolf (GESIS – Leibniz Institute for the Social
Sciences, since 2012). Neither the funding organisation nor the
principal investigators bear any responsibility for the example code
shown here.