The only line that should be different is 207, where one returns the summary and the other the complete object.
control <- gsub("~ bbbb", "", control, fixed = TRUE)
control <- gsub("~", "", control, fixed = TRUE)
control <- gsub("bbbb", "", control, fixed = TRUE)
control <- gsub("~bbbb", "", control, fixed = TRUE)
Also in terms of maintainability, there should probably be a single function that generates the Cox model and applies the disclosure control (this might be called coxphSLMADS). Then there should be two other functions for the aggregate and assign operations, that call the main function. The aggregate would just call the main function, then do summary()
on the coxph
object and return to the client. The assign just returns the coxph
object which stores it on the server side. That way the bulk of the code is in one place.