You misunderstand what load does. It restores an object with the same name as with save() d. What you see in M is the return value of the load() function. The load() call has an additional side effect of returning the object back under the same name with which it was saved.
Consider:
require("e1071") data(iris)
Now let's look at the workspace
> ls() [1] "iris" "M" "model"
Consequently, model was restored as a side effect of load() .
From ?load we see that the reason M contains the name of the created (and, therefore, originally saved) objects
Value: A character vector of the names of objects created, invisibly.
If you want to restore the object for a new name, use saveRDS() and readRDS() :
saveRDS(model, "svm-model.rds") newModel <- readRDS( "svm-model.rds") ls() > ls() [1] "iris" "M" "model" "newModel"
If you want to know more about saveRDS() and readRDS() , see the related help ?saveRDS() , and you might be interested in a blog post that I wrote on this topic .
source share