I'm new to Rscript
so please bear with me, I need to execute a R script (written by another developer) from java and for that I'm using Renjin
. The R script file and other required files are on classpath
ie under resources folder.
To achieve this I'm loading Rscript
from classpath and it gets loaded successfully, and Rscript
tries to load a abc.Rda
file internally which is also present in classpath (parallel to R script), the code for same is below
load('abc.Rda')
But when I try to execute script then it throws exception as below:
Could not read from "file:///D:/data/{project-dir}/abc.Rda" because it is a not a file.
Please suggest where I'm making mistake.
I'm not sure why using the absolute path didn't work: perhaps the script is incorrectly calling setwd(dir='/bad/{project-dir}')
somewhere earlier?
Renjin actually mediates file system operations through Apache Virtual File System (VFS). So if you specifically want a resource on the classpath, you can use the "res:" protocol, for example:
load('res:com/acme/mypackage/abc.Rda')
This should work whether the file is actually on the filesystem or packaged as part of a jar or other archive.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.