Tôi muốn tạo danh sách trống để tôi có thể thay thế các phần tử của nó bằng các danh sách khác.tạo danh sách trống để điền vào danh sách trong R
Ví dụ
simulations = 10
seeds = sample(10000:99999, simulations, replace=F)
test_function <- function(seedX){
lista = list(seedX=seedX,
dataframe=data.frame(x=runif(10, -5.0, 5.0),y=rnorm(10,mean = 0,sd = 1)))
return(lista)
}
results <- vector("list", simulations)
results[1] = test_function(seedX = seeds[1])
tôi nhận được lỗi sau:
Warning message:
In results[1] = test_function(seedX = seeds[1]) :
number of items to replace is not a multiple of replacement length
Tôi đang làm gì sai?
Cảm ơn!