2019 November 28
library(openxlsx) students <- c(2001234567,2012345678,2000000123) nStudents <- length(students) n <- 100 datasets <- vector('list',nStudents) for (i in 1:nStudents) { x1 <- rnorm(n,4,1) x2 <- rgamma(n,4,2) y <- 20 + 2*x1 + rnorm(n) datasets[[i]] <- data.frame(y,x1,x2) } names(datasets) <- paste0('St',students) write.xlsx(datasets, file = "Practical1data.xlsx")