s-u / REngine

General Java interface to R supporting multiple back-ends such as JRI and Rserve
Other
67 stars 47 forks source link

Getting list of files available on Rserve #14

Closed hlms closed 3 years ago

hlms commented 7 years ago

Using RConnection#openFile(String filepath), a user can open a file on the Rserve for reading.

Is there a way get the list of all files available?

Need to browse through the files available. Then I can pick one file for reading.

s-u commented 7 years ago

eval("Sys.glob('...')") is probably your friend here. Don't forget you can use all facilities of R.

hlms commented 7 years ago

@s-u , I do NOT have much information about R.

I have an R user credentials.

Need to write a java program which displays the list of files/directories available on the server on which R is installed (using R user credentials only). User would navigate through the directories, and would select one file. My java code would fetch the file.

If the R instance has R serve package installed, my java code can use REngine.jar and use list.files and list.dirs commands in eval():

Will need to manipulate the output of this two commands to generate a single list. A wrapper java program can be written using these two commands so that user will be able to navigate through the files/directories.

It is easy for linux server. There is one tree of files - linux file-system.

It gets tricky when R instance is on a windows machine. Need to get the list of drives on the machine:

> system("cmd.exe /c wmic logicaldisk get name", intern = F)
Name  
C:    
D:    

Need to check the OS as following:

> .Platform$OS.type
[1] "windows"

So, the flow differs based on underlying OS - windows or unix-like.

  1. Is there a way to write my java program which is NOT dependent on the underlying OS of the server on which R is installed?
  2. Are there any REST APIs for listing files/directories or any R pacakages which would help me achieve the same?
  3. Can I remove the file business at all? Is there a way to just get a particular "report"? (Not sure, if the "report" term exists for R). Run a particular script on R, and just give me the output of the script in response of some API. Are there such APIs?