Using a Random Forest from Caret in Shiny

Hello all, I am pretty new to shiny, but I haven't been able to find much help on this problem.

I am creating a shiny app that relies on the results from a random forest model (from the caret package) to run a predict() function. (Basically the user puts in data and shiny uses the predict function (which of course must have the results from the random forest model) to give back the probabilities of various outcomes based on the data. This works fine in my global environment since I already have the model loaded, but obviously when I publish the app, I need to be able to load in the results from the random forest for other users to have. I was curious how to save the results from the random forest (what the predict() function takes as a parameter) to a file or something that I could load in without having to run the random forest every single time the app starts? (The random forest is pretty long and takes about an hour+ to run). Obviously, you can't save it to a CSV, but is there any way that you could save it to a different kind of file? Is there a solution that I'm not thinking of?

Thanks

You can save most R objects with saveRDS()

Thank you!!! You the man!

I was able to save it and bring it back just dandy when I saved it to my local computer, but I was trying to save it to Dropbox and bring it back (so it could be used by any user that uses a shiny application), and when I tried load(url("[insert sharable link here]")) I got an error that says "the input does not start with a magic number compatible with loading from a connection." Any ideas how to solve that?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.