Create a class of arm.
Public methods in this R6 class are used in developing this package. Thus, we have to export the whole R6 class which exposures all public methods. However, only the public methods in the list below are useful to end users.
$add_endpoints()add one or multiple endpoints to the arm.$print()print a summary report of the arm based on example data of its endpoints.
In addition, $generate_data() and $get_endpoints() are for
exploratory purpose only. They appear in examples and vignettes to help
users understand how this class works, but they are not needed at all in
formal simulation once users know how to use this package.
Internal machinery. The remaining public methods
($get_name(), $get_endpoints_name(), $has_endpoint()
and $update_endpoint_generator()) are public only because they are
invoked on an arm object by other components of the package (trials),
which R6 cannot grant through private members. Users should not call them
directly.
Value
an R6Class generator object; use arm() to create an arm.
Methods
Method new()
initialize an arm
Usage
Arms$new(name, ...)Arguments
namename of arm, which is the arm's label in generated data. It must not contain
'@'or';', which are reserved for encoding the treatment switching history (regimen_trajectory) of trials with a regimen....subset condition that is compatible with
dplyr::filter. This can be used to specify inclusion criteria of an arm. By default it is not specified, i.e. all data generated by the generator will be used as trial data. More than one conditions can be specified in....
Method add_endpoints()
add one or multiple endpoints to the arm.
Arguments
...one or more objects returned from
endpoint().
Examples
a <- arm(name = 'trt')
x <- endpoint(name = 'x', type = 'tte',
generator = rexp) # median = log(2)/1 = 0.7
y <- endpoint(name = 'y', type = 'non-tte', readout = c(y = 0),
generator = rnorm, sd = 1.4, mean = 0.7)
a$add_endpoints(y, x)
## run it in console to see the summary report
a
print(a) # use the print method
Method has_endpoint()
INTERNAL MACHINERY: DO NOT CALL THIS METHOD DIRECTLY.
check if the arm has any endpoint. Return TRUE or FALSE.
Method get_endpoints_name()
INTERNAL MACHINERY: DO NOT CALL THIS METHOD DIRECTLY.
return name of endpoints registered to the arm.
Method update_endpoint_generator()
INTERNAL MACHINERY: DO NOT CALL THIS METHOD DIRECTLY.
update generator of an endpoint object
Arguments
endpoint_namecharacter. A vector of endpoint names whose generator is updated.
generatora random number generation (RNG) function. See
generatorofendpoint()....optional arguments for
generator.
Method print()
print an arm.
Examples
# Instead of using Arms$new(), please use arm(), a user-friendly
# wrapper. See examples in ?arm
## ------------------------------------------------
## Method `Arms$add_endpoints`
## ------------------------------------------------
a <- arm(name = 'trt')
x <- endpoint(name = 'x', type = 'tte',
generator = rexp) # median = log(2)/1 = 0.7
y <- endpoint(name = 'y', type = 'non-tte', readout = c(y = 0),
generator = rnorm, sd = 1.4, mean = 0.7)
a$add_endpoints(y, x)
## run it in console to see the summary report
a
#> Summary generated.
print(a) # use the print method
#> Summary generated.