Chaining function calls

OpenCPU is plain HTTP and therefore each call is stateless. The client does not have a single dedicated R process. Instead, the client can pass the returned object from a function call as an argument to a subsequent function call using its session ID.

One way to think about this is as an R variable assignment, however instead of specifying an arbitrary variable name yourself, the system assigns the object to a unique ID. So for example in R you might want to run the following commands:


mydata <- read.csv(file="mydatafile.csv", header=TRUE)
summary(object=mydata)    
    

In OpenCPU you accomplish the same thing by first calling read.csv, which returns an ID. Then you call summary and pass the given ID as the value for the argument object.

In the example below we do almost exactly this, except for that we use functions readcsvnew and printsummary which are included with this package.

CSV File
Header