I am currently working on the Boston
data. So I downloaded the library(MASS) data(Boston). As I found on numerous websites there is a famous assignment on this based on this regression model (OLS) medv = β0 + b1crim + b2chas + ε
. I now want to draw a random sample of X
observations e.g. 30 and save the subsample as object ZZ
. How can I do this?
Asked
Active
Viewed 55 times
0

Ben Bolker
- 211,554
- 25
- 370
- 453
2 Answers
0
You probably want
data("Boston", package = "MASS")
keep_rows <- sample(nrow(Boston), size = 30, replace = FALSE)
ZZ <- Boston[keep_rows, ]

Ben Bolker
- 211,554
- 25
- 370
- 453