[R-sig-ME] Basic file management -- How to write.table of ranef()

Ben Bolker bbolker at gmail.com
Thu May 12 21:09:55 CEST 2011

Hash: SHA1

On 05/12/2011 03:01 PM, Jeremy Koster wrote:
> Hi all,
> Apologies for asking such a simple question, but I have been trying
> to use write.table to export the random-effect intercept estimates
> for a straightforward two-level varying-intercept model using lme4.
> For instance, after estimating the model, this code produces a list
> of the estimated intercepts:
> ranef(full.model)
> Then I assign those estimates to an object:
> random.intercepts <- ranef(full.model)
> Whenever I try to use write.table to export those estimates, however,
> I get an error message that the object cannot be coerced into a data
> frame.

 Use str() to see what the structure of the object actually is.  I think
it's a list of data frames.

  (For example:


List of 1
 $ Subject:'data.frame':	18 obs. of  2 variables:
  ..$ (Intercept): num [1:18] 2.26 -40.4 -38.96 23.69 22.26 ...
  ..$ Days       : num [1:18] 9.2 -8.62 -5.45 -4.81 -3.07 ...
 - attr(*, "class")= chr "ranef.mer"

  Some options for exporting the information are: dput(), sink(); or
using write.table() to send the individual chunks.


  Might work for a two-level model (although you may end up with a file
that's hard to read back into R, since it may have unequal numbers of
columns and will have header rows in the middle of the file if you have
multiple grouping variables).

  What do you want to do with the output file?

> File management is clearly not my strong suit, but am I assuming
> correctly that there should be a relatively painless way of
> accomplishing this?  Any suggestions?
> Thanks!
> _______________________________________________ 
> R-sig-mixed-models at r-project.org mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/


More information about the R-sig-mixed-models mailing list