[R] Format of Output of Residuals

Michael Just mgjust at gmail.com
Fri Oct 1 06:09:13 CEST 2010


An excerpt from dataset ChickWeight:
    weight Time Chick Diet
1       42    0     1    1
2       51    2     1    1
3       59    4     1    1

I am interested in the residuals of the dataset.  Specifically in
saving them to another format. I have been creating text files with
sink.

CW.lm <- lm(weight ~ Diet, ChickWeight)
resid.CW.lm <- resid(CW.lm)

But when I call:
resid.CW.lm

The data appears like this (excerpt) :

           1            2            3            4            5            6
 -60.6454545  -51.6454545  -43.6454545  -38.6454545  -26.6454545   -9.6454545

How can I get the data to be formatted like below in an output / sink
friendly way?

1 -60.6454545
2 -51.6454545
3 -43.6454545
4 -38.6454545
5 -26.6454545
6 -9.6454545

Thank you kindly,
Cheers,
Mike



More information about the R-help mailing list