问题
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.
回答1:
For example ,
lm(x~y,data = A[30:80,])
Or using subset
parameter:
lm(x~y,data=A,subset=30:80)
来源:https://stackoverflow.com/questions/20214504/how-to-run-linear-model-in-r-with-certain-data-range