[R] creating a list based on various mean values
Erin Hodgess
erinm.hodgess at gmail.com
Fri Oct 23 10:51:37 CEST 2015
Hello!
I would like to create a list of random values, based on various means.
Here are the potential mean values:
> k1
[1] 0.005 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000
1.100 1.200 1.300 1.400
[15] 1.500 1.600 1.700 1.800 1.900 2.000 5.000 10.000
There are 22 of them.
My original thought was to use "do.call" to produce a list of 22 items of
size 20.
> xr <- do.call("rnorm",args=list(n=20,mean=k1))
> xr
[1] -1.46443269 0.83384389 0.39176720 -0.17954959 0.28245948
-0.44148055 1.98009926 1.73881739
[9] 1.37312454 1.40509257 -0.03762214 0.43636354 1.82175069
1.96439065 2.71731752 1.02388062
[17] 1.20732047 3.08650964 0.87910868 0.13018727
>
However, I am just getting back one set of size 20. What am I doing wrong,
please? Or do I need to do a loop, please? I thought that there must be a
more elegant solution.
This is on a Macbook Air, R version 3.2.2
Thanks so much,
Sincerely
--
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
[[alternative HTML version deleted]]
More information about the R-help
mailing list