Sueli Rodrigues <srodrigu <at> esalq.usp.br> writes:
> 
> Olá. Tenho um arquivo que a cada 6 linhas corresponde uma amostra da qual
> preciso dos coeficientes da regressão linear. Como faço para que o
> programa distinga a cada 6 linhas como uma amostra e não calcule como um
> todo?
> Estou usando a função: model=lm(y ~ x)
> 

  You're more likely to get a response if you post to the list
in English (even fractured English).

 Based on what Google translator thinks you said (you want
to perform linear regressions on 6-line subsets of a data set?),
here's a starting point (assuming your data are in a data frame
mydata, and have column names x and y):

splitdat <- split(mydata,rep(1:6,length.out=nrow(mydata))
linfits <- lapply(splitdata,lm,formula=y~x)
coefs <- sapply(linfits,coef)

or something like that.

  Ben Bolker

______________________________________________
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