Closed luyckxn closed 3 years ago
After some reflexion, I'm not really in favour to implement custom methods to modify a specific slot in a S4 object.
1) One generic way to modify a slot in a S4 object (which is used many times in the examples) is to do as follows:
# Retrieve the first arm from the dataset (or anything else)
arm <- dataset@arms %>% getByIndex(1)
# Modify a slot
arm@subjects <- as.integer(<NEW_NUMBER>)
# Replace old arm in dataset
dataset <- dataset %>% replace(arm)
2) Proposed workaround in ticket is fine as well:
dataset@arms@list[[1]]@subjects <- as.integer(<NEW_NUMBER>)
3) Create custom and parameterized functions in your simulation script:
createArm <- function(subjects) {
arm <- Arm(subjects=subjects)
return(arm)
}
There is no easy way to update the number of subjects in the dataset.
Add a new function updateSubjects(newValue, armId=0 (default)) ?
A current workaround is to write: dataset@arms@list[[1]]@subjects <- 1