Calling R script with Javascript

LabKey Support Forum (Inactive)
Calling R script with Javascript bront  2013-12-02 14:22
Status: Closed
 
hi,

I have been working on creating a generic R-script that I can pass config parameters via Javascript. This works.

Is there a way, however, to pass references to different tables/views?

I was unsuccessful when I tried to modify read.table("${input_data}", header=TRUE, sep="\t") to accept a different dataset.

The following does not look promising...

"Views created independently of grid views do not have access to labkey.data objects. Such views are listed under the None heading in the list on the Manage Views page."

from : https://www.labkey.org/wiki/home/Documentation/page.view?name=rBuilder

Many thanks,

b
 
 
jeckels responded:  2013-12-02 14:59
Hi Bront,

Only the query associated with the R report will be available as a TSV on the file system (which is automatically available as labkey.data.

However, you can make separate calls to get other data using the Rlabkey package. See the documentation for the selectRows or executeSql functions here:

http://cran.r-project.org/web/packages/Rlabkey/Rlabkey.pdf

The R script will be running as the user who initiated the request (not the developer), and will have their permissions when making API calls like that.

Thanks,
Josh
 
bront responded:  2013-12-03 13:39
Josh,

Looks good.

As always, thanks for your prompt help.

cheers,

bront