Displaying 1 result from an estimated 1 matches for "tp1597064p1597400".
Did you mean:
tp1597064p1597102
2010 Mar 17
2
How to use "ifelse" to generate random value from a distribution
I need use different parameters of distribution for different case to
generate random value, but I use ifelse, the generated value is fixed
without change.
Here is example
data1
y x
1 1 2
2 2 1
3 3 2
4 4 3
5 5 3
6 6 1
7 7 2
8 8 1
9 9 1
10 10 3
11 11 3
12 12 2
ifelse(data1$x==1,rnorm(1,2,1),ifelse(data1$x==2,rnorm(1,-2,1),rnorm(1,110,1)))
[1] -1.8042172 0.8478681