set_obj_method: update method for a struct object

Description Usage Arguments Value Examples

View source: R/struct_class.R

Description

a helper function to update methods for a struct object

Usage

1
2
3
4
5
6
7
set_obj_method(
  class_name,
  method_name,
  definition,
  where = topenv(parent.frame()),
  signature = c(class_name, "DatasetExperiment")
)

Arguments

class_name

the name of the to update the method for

method_name

the name of the method to update. Must be an existing method for the object.

definition

the function to replace the method with. This function will be used when the method is called on the object.

where

the environment to create the object in. default where = topenv(parent.frame())

signature

a list of classes that this object requires as inputs. Default is c(class_name,'DatasetExperiment')

Value

a method is created in the specified environment

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set_struct_obj(
class_name = 'add_two_inputs',
struct_obj = 'model',
stato = FALSE,
params = c(input_1 = 'numeric', input_2 = 'numeric'),
outputs = c(result = 'numeric'),
prototype = list(
   input_1 = 0,
   input_2 = 0,
   name = 'Add two inputs',
   description = 'example class that adds two values together')
)

struct documentation built on Nov. 8, 2020, 8:14 p.m.