Difference between revisions of "Workspace Interaction From R"
From Gcube Wiki
(→Functions) |
(→Functions) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
<source lang="java"> | <source lang="java"> | ||
+ | #REMOTE IMPORT OF ALL FUNCTIONS - OPTIONAL | ||
+ | source("http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/workspace_interaction.r") | ||
+ | |||
#SETTING USERNAME AND TOKEN - NOT NEEDED WHEN USING RSTUDIO ON THE PORTAL | #SETTING USERNAME AND TOKEN - NOT NEEDED WHEN USING RSTUDIO ON THE PORTAL | ||
username<<-"gianpaolo.coro" | username<<-"gianpaolo.coro" | ||
Line 21: | Line 24: | ||
a<-listHomeWS() #GET THE LIST OF FOLDERS IN THE WS ROOT | a<-listHomeWS() #GET THE LIST OF FOLDERS IN THE WS ROOT | ||
b<-listWS("/Home/gianpaolo.coro/Workspace/TestSAI/") #GET THE LIST OF FILES AND FOLDERS IN ONE SUB-FOLDER | b<-listWS("/Home/gianpaolo.coro/Workspace/TestSAI/") #GET THE LIST OF FILES AND FOLDERS IN ONE SUB-FOLDER | ||
+ | |||
+ | |||
+ | #CREATING A NEW FOLDER | ||
+ | pathonthews<-"/Home/gianpaolo.coro/Workspace" | ||
+ | folderName = "MyNewFolder" | ||
+ | newFolderID = createPrivateFolder(path=pathonthews,foldername=folderName) | ||
+ | checkf<-listWS("/Home/gianpaolo.coro/Workspace/MyNewFolder/") | ||
+ | |||
+ | #CREATING A NEW FOLDER WITH A DESCRIPTION | ||
+ | pathonthews<-"/Home/gianpaolo.coro/Workspace/MyNewFolder/" | ||
+ | folderName = "MyNextFolder" | ||
+ | description = "MyNextFolder description" | ||
+ | newFolderID = createPrivateFolderWithDescription(path=pathonthews,foldername=folderName,description = description) | ||
#DOWNLOADING | #DOWNLOADING |
Latest revision as of 16:00, 8 October 2020
Overview
This page reports examples to interact with the online Workspace (WS) from R.
Key features
- interaction with R
- saving files and folders on the WS
- downloading files and folders from the WS
Functions
- INITIAL STEP: Import the D4Science interaction functions R container script. This step is not necessary when using the RStudio instance on one of the Web portals.
#REMOTE IMPORT OF ALL FUNCTIONS - OPTIONAL source("http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/workspace_interaction.r") #SETTING USERNAME AND TOKEN - NOT NEEDED WHEN USING RSTUDIO ON THE PORTAL username<<-"gianpaolo.coro" token<<-"..." #YOUR TOKEN FOR A VRE #LISTING a<-listHomeWS() #GET THE LIST OF FOLDERS IN THE WS ROOT b<-listWS("/Home/gianpaolo.coro/Workspace/TestSAI/") #GET THE LIST OF FILES AND FOLDERS IN ONE SUB-FOLDER #CREATING A NEW FOLDER pathonthews<-"/Home/gianpaolo.coro/Workspace" folderName = "MyNewFolder" newFolderID = createPrivateFolder(path=pathonthews,foldername=folderName) checkf<-listWS("/Home/gianpaolo.coro/Workspace/MyNewFolder/") #CREATING A NEW FOLDER WITH A DESCRIPTION pathonthews<-"/Home/gianpaolo.coro/Workspace/MyNewFolder/" folderName = "MyNextFolder" description = "MyNextFolder description" newFolderID = createPrivateFolderWithDescription(path=pathonthews,foldername=folderName,description = description) #DOWNLOADING remoteFile<-"/Home/gianpaolo.coro/Workspace/DataMiner/sample.xml" #REMOTE FILE TO DOWNLOAD downloadFileWS(remoteFile) #DOWNLOAD THE FILE LOCALLY folder<-"/Home/gianpaolo.coro/Workspace/TestSAI" #REMOTE FOLDER TO DOWNLOAD downloadFolderWS(folder) #DOWNLOAD THE FOLDER CONTENT LOCALLY #UPLOADING wsfolder<-"/Home/gianpaolo.coro/Workspace/TestUploads" #REMOTE DESTINATION FOLDER file="userconfig.csv" #LOCAL FILE TO UPLOAD overwrite<-T #CHOOSE IF THE FILE SHOULD BE OVERWRITTEN q<-uploadWS(wsfolder,file,overwrite) #UPLOAD THE FILE TO THE WS #UPLOADING THE COMPLETE LOCAL R WORKSPACE ONTO THE E-INFRA WS uploadAllWS(wsfolder) #OBTAINING A PUBLIC URL FOR A FILE (FOR NON-VRE FOLDERS) remotefile<-"/Home/gianpaolo.coro/Workspace/splist.txt" publicURL<-getPublicFileLinkWS(remotefile) #UPLOAD TO THE ROOT OF THE VRE FOLDER CORRESPONDING TO THE USER TOKEN outcome<-uploadToVREFolder("",'sampletext2.txt',T,F) #UPLOAD TO A SUBFOLDER OF THE VRE FOLDER outcome<-uploadToVREFolder("Samples/",'sampletext2.txt',T,F) #UPLOAD TO A SUBSUBFOLDER OF THE VRE FOLDER outcome<-uploadToVREFolder("Samples/TextSamples/",'sampletext2.txt',T,F) #GET FILE LINK FROM THE ROOT VRE FOLDER link<-getPublicFileLinkVREFolder('sampletext2.txt') #GET FILE LINK FROM A FILE IN A SUBFOLDER OF THE VRE FOLDER link<-getPublicFileLinkVREFolder('Samples/sampletext2.txt') #DOWNLOAD FILE FROM THE ROOT VRE FOLDER downloadFromVREFolder('sampletext2.txt') #DOWNLOAD FILE FROM A SUBFOLDER OF THE ROOT VRE FOLDER downloadFromVREFolder('Samples/sampletext2.txt')