jeudi 16 avril 2020

Generating random series based on means and standard deviations from a dataframe

I am practicing with dataframe and I have a table like this: example table

How can I generate 18 x 30 = 540 data points in which each 30 dataset is a random series of n=30, A_i, stdev_A_i (i=1->18).

The method of

rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) } 

r <- rnorm2(30,A,Stdev_A) print(unname(as.data.frame(r)),quote = FALSE, row.names = FALSE)

only generates 30 data points at a time and I have to manually do it for 18 times.

Thank you.




Aucun commentaire:

Enregistrer un commentaire