Skip to content
Prev 6038 / 20628 Next

Basic file management -- How to write.table of, ranef()

On Thu, May 12, 2011 at 4:25 PM, Petar Milin <pmilin at ff.uns.ac.rs> wrote:
In the sense of one for each distinct grouping factor. There can be
more than one random-effects term associated with the same grouping
factor and, in that case, the conditional means of the random effects
are combined into one data frame.
Those will work but are somewhat redundant.  As Ben pointed out, if
you use str() on the result of ranef() you will find that it is a list
of data frames - one per grouping factor.  Thus a simple

rr <- ranef(lmer1)
write.table(rr$A)  # rr$A is already a data frame

will work.

Your last suggestion doesn't quite work because ranef(lmer1)[1] is
itself a list.  You need two brackets, as in ranef(lmer1)[[1]] to get
the data frame.  It is like that distinction between a subset of size
1 (the single bracket form) and that particular element of the set
(double brackets).