Pregunta

I run a linear model on my dataset which has the dimension of 2 columns and 100 rows. How could I run the model for a certain data range e.g from row 30 to row 80?

set.seed(123)     # allow reproducible random numbers
A <- data.frame(x=rnorm(100), y=runif(100))# 2 columns with 100 rows of data
fit.lm <- lm(A$x~A$y) #fit 100 data
summary(fit.lm)# summary 100 data

Thanks in advance.

¿Fue útil?

Solución

For example ,

lm(x~y,data = A[30:80,])

Or using subset parameter:

lm(x~y,data=A,subset=30:80)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top