Generation of Normal Random Numbers
m <- c(1004.1, 1028.3, 1044.3, 861.4) s <- c(194.5899, 158.7052, 123.3000, 285.8695) x <- mapply(function(mi, si) rnorm(25, mi, si), m, s) Hope this helps, Michael
On 11 January 2011 17:44, saggak <saggak1908 at yahoo.co.in> wrote:
Dear R helpers I have a data frame as given below df = data.frame(A = c(776,827,836,995,855,1026,1203,1363,965,1195), ?????????????????????? B = c(806,953,1049,1056,1243,764,1148,1162,948,1154), ?????????????????????? C = c(959,1155,1193,1163,863,1070,1087,877,1132,944), ?????????????????????? D = c(906,760,978,1170,1009,883,1007,960,828,113)) # Actually the real data has number of vectors and not only A, B, C and D. m = as.numeric(lapply(df, mean)) s = as.numeric(lapply(df, sd)) gives
m
[1] 1004.1 1028.3 1044.3? 861.4
s
[1] 194.5899 158.7052 123.3000 285.8695 I need to generate 25 (normal) random numbers for each of these mean and corresponding standard deviation combination (m[i], s[i]). i.e. I need to have a table (dim 25 X? 4) giving me random numbers. rnorm(25, m[1], s[1])?? rnorm(25, m[2], s[2])?? rnorm(25, m[3], s[3])? rnorm(25, m[4], s[4]) ?? ....................?????????? .........................?????????? ............... ? ? ? ? ? ? ? ? ................. ?? ....................?????????? .........................?????????? ............... ? ? ? ? ? ? ? ? ................. ?? ....................?????????? .........................?????????? ............... ? ? ? ? ? ? ? ? ................. ?? ....................?????????? .........................?????????? ............... ? ? ? ? ? ? ? ? ................. ?? ....................?????????? .........................?????????? ............... ? ? ? ? ? ? ? ? ................. Kindly guide Thanking in advance Sagga K ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.