Most R model implementations store the training data within the fitted object, often many times. It can be useful to remove the embedded data for portability, especially if the only required functionality is to predict on new data.
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  purge(model)
## Default S3 method:
purge(model)
## S3 method for class 'glm'
purge(model)
## S3 method for class 'lm'
purge(model)
## S3 method for class 'merMod'
purge(model)
## S3 method for class 'glmerMod'
purge(model)
## S3 method for class 'rpart'
purge(model)
## S3 method for class 'randomForest'
purge(model)
## S3 method for class 'ranger'
purge(model)
## S3 method for class 'coxph'
purge(model)

model 
A fitted R model object 
A fitted R model object, purged of its training data, but retaining its predict functionality on new data
default
: Default purge returns a copy of the model
glm
: Purges a glm model
lm
: Purges an lm model
merMod
: Purges a merMod, linear mixedeffects model
glmerMod
: Purges a glmerMod, generalized linear mixedeffects model
rpart
: Purges an rpart model
randomForest
: Purges a random forest model
ranger
: Purges a ranger model for classification, regression, or survival
coxph
: Purges a coxph model
1 2 3 4 5 6  x < rnorm(1000)
y < x + rnorm(1000)
unpurged.model < lm(y ~ x)
purged.model < purge(unpurged.model)
object.size(unpurged.model)
object.size(purged.model)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.