Hi,

Works for me:

samp$Resid <- as.numeric(do.call("c",by(samp, samp$Race,
function(x)resid(lm(stroke~Sex+Age, data=x)))))


On 24/10/2007, Jiong Zhang, PhD <[EMAIL PROTECTED]> wrote:
>
> Hi Folks,
>
> I want to get the regression residue which each Race. But using:
> sample$resid <- by(sample,sample$Race),function(x)resid(lm( stroke ~ Sex +
> Age + Smoker + BMI, data = x)))
> Does not work. How do I calculate residue by grops?
>
> thanks.
>
> jiong
> The email message (and any attachments) is for the sol...{{dropped:20}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to