[R] Opencpu and caching
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Sat Apr 29 02:23:19 CEST 2017
You have already been told this is the wrong list for these questions. Go ask in the OpenCPU support areas.
My very limited understanding of OpenCPU is that what you are asking for is specifically not supported. You need to setup your own function that does everything before it returns.
--
Sent from my phone. Please excuse my brevity.
On April 28, 2017 4:42:15 PM PDT, Jake Stone <jake at jakestone.net> wrote:
>I am new to opencpu. My specialty is java. I use R for very specific
>analyses.
>
>*PROBLEM*
>My understanding is that each API call to opencpu opens a new R
>session.
>My function will classify the data input using the predict method of a
>linear discriminant analysis (lda from MASS package).
>The initial linear discriminant analysis on 100000+ cases and 150+
>factor
>levels takes time (over 30 seconds). This function returns a list.
>The subsequent prediction function is quick and returns a simple
>vector.
>
>
>*APPROACH*
>I run one opencpu function to run the initial lda. This only needs to
>run
>once.
>I want my second function to ONLY run the predict function. This is
>possible if the lda is held as a global variable.
>My understanding is that global variables are not possible in opencpu.
>So I
>will have to cache the lda on the file system.
>In sum, I need to run the lda just once and hold the analysis (a list)
>either in memory or on the file system. I then retrieve the lda
>analysis
>when predict is called.
>
>*QUESTION*
>Which approach is best, and how to implement?
>1. I could use an opencpu function that creates and returns the lda.
>Then
>when I call a prediction, I could retrieve the lda object (a list) from
>the
>file system. But how do I retrieve the list from the file system. How
>does opencpu even know where it is?
>2. I could use r.cache package. I haven't used this package before but
>the
>docs suggest it is a solution. Will this work?
>
>Any advice would be deeply appreciated.
>
>best
>jake
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list