# principal components homework

#### Snowy88

##### New Member
Please assist in how do I remove every tenth observation from a data set to use as a test sample and the remaining data as a training sample building a linear regression then a linear regression using AIC:

I know how to set up the linear model but how do I remove observations in an equation?

fit<-lm(density~., fat)

#### Dason

##### Ambassador to the humans
You don't remove it in the equation. You create two separate datasets. Here is one way to do it using mtcars as an example

Code:
id <- seq(1, nrow(mtcars), by = 10)
test <- mtcars[id,]
train <- mtcars[-id,]