Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to import an R model generated in one computer to R on another computer?

I have 7 training models in total. All of them are created using caret::train function.
5 of them are generated with R in one laptop(Mac), while the other 2 are generated with R in another laptop(PC). I need to output a chart. Before that I need to use caret::resamples function to generate the result. That means I will need all 7 models in the same environment. Is there any code I can write to do that?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Actually, as of Axeman’s comment, you can use saveRDS(model, "model.rds") and model <- readRDS("model.rds"), but you don’t need to use .RData in order to use the .rds files. You can just add the lines of code in your scripts!

You can do so for each model in your environment:

saveRDS(model1, "model1.rds")
saveRDS(model2, "model2.rds")

and so on, then transport to another computer however you’d like, and read:

model1 <- readRDS("model1.rds")
model2 <- readRDS("model2.rds")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading