-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.R
37 lines (31 loc) · 623 Bytes
/
rc.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Random <- setRefClass(
"rnd",
fields = list(),
methods = list()
)
norm_rnd <- setRefClass(
"norm",
contains = "rnd",
fields = list(mu="numeric",sigma="numeric"),
methods = list(
rnorm_gen = function(mu,sigma)
r <- rnorm(1,mu,sigma)
)
)
beta_rnd <- setRefClass(
"beta",
contains = "rnd",
fields = list(shape1="numeric", shape2="numeric"),
methods = list(
rnd_beta = function()
{
rbeta(1,shape1,shape2)
}
)
)
print.rnd <- function (x , ... ) {
print ( paste0 ("I am of type : " , class (x)))
}
b <- beta_rnd$new(shape1=2,shape2=3)
b$rnd_beta()
print.rnd(b)