Run a command in an external application.
Syntax
xrun command
xrun is used to run a command in an external COM application (either R or MATLAB). An existing connection to the external application must have already been opened using xopen. xrun should be followed by the command you wish to run.
Examples
xopen(type=m, case=upper)
xput Y
xput XS
xrun beta = inv(XS'*XS)*XS'*Y
opens a connection to MATLAB, sends the series Y and the group XS to MATLAB, then runs a command which will compute the least squares coefficients from a regression of Y on XS.
The commands
xopen(type=r, case=upper)
xput(rtype=data.frame, name=cancer) age drug2 drug3 studytim
xrun z<-glm(STUDYTIM~AGE+1+DRUG2+DRUG3, family=Gamma(link=log),data=cancer)
send data to R and estimate GLM model.
Note that the statconnDCOM package does not always automatically capture all of your R output. Consequently, you may find that using xrun to issue a command that displays output in R may only return a subset of the usual output to your log window. In the most extreme case, you may see a simple “OK” message displayed in your log window. To instruct statconnDCOM to show all of the output, you should use enclose your command inside an explicit print statement in R. Thus, to display the contents of a matrix X, you must issue the command
xrun print(X)
instead of the more natural
xrun X
Cross-references