I am trying to generate random numbers with sequence for my data.list
below. Since I cannot load my real data here to ask detailed question, I try to create reproducible example always to help to other users.
I want to generate sequence of random numbers for each element time
,Mx
,My
,Mz
with incresing order as in the below code not the sample
them like in this example. how to generate random numbers with sequence in R
data.list <- lapply(1:5, function(x) {
nrep <- 20
time <- rep(seq(90,54144,length.out=601),times=nrep)
Mx <- rep(seq(0.012,-0.014,length.out = 601), times=nrep)
My <- rep(seq(0.02,-0.02,length.out = 601), times=nrep)
Mz <- rep(seq(-1,1,length.out=601),times=nrep)
data.frame(time,Mx,My,Mz)
})
as you can see the image below, each set has 20 set of data. It would be nice to create different time
,Mx
,My
,Mz
values for each set.
Aucun commentaire:
Enregistrer un commentaire