문제

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.

도움이 되었습니까?

해결책

For example ,

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

Or using subset parameter:

lm(x~y,data=A,subset=30:80)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top