You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
697 B

# Load data
house.df <- read.csv("WestRoxbury.csv")
# Extract the row numbers
house.rows <- row.names(house.df)
# Partition the row numbers into 10 equal subsets
set.seed(100)
house.rows.list <- list()
for(i in 1:10){
house.rows.list[[i]] <- sample(house.rows, length(house.rows) / (10 - i + 1))
house.rows <- setdiff(house.rows, house.rows.list[[i]])
}
# Partition the data into 10 equal subsets
house.df.list <- list()
for(i in 1:10){
house.df.list[[i]] <- house.df[house.rows.list[[i]],]
}
# Display the number of observations in each subset
for(i in 1:10){
print(paste("Number of observations in subset", i,
"=", dim(house.df.list[[i]])[1]))
}