deployrExternal: Access big data files in a portable way across environments.

View source: R/deployrExternal.R

deployrExternalR Documentation

Access big data files in a portable way across environments.

Description

If you need to work with very large data files and want your R code to run consistently when accessing those files locally and on the DeployR Server, then use the deployrExternal function. This function provides you with a consistent way of referencing these big data files for reading and writing; thereby, making your R code portable.

Important! In order to get your big data files into the DeployR environment, you must first ask the DeployR administrator to place a copy of those files in the appropriate external directory on the server on your behalf. Once the files have been copied onto the server, your R code can reference these files by specifying the filename as an argument on the deployrExternal function.

When your code executes locally, the function looks for the data files in the current working directory of your R session. When your code executes remotely on the DeployR server, the function looks for the data files in the dedicated external directories configured and managed by the DeployR administrator.

For more information on configuring or using external directories, see the ‘Writing Portable R Code’ document for your DeployR version on the official DeployR website (http://go.microsoft.com/fwlink/?LinkId=708337).

Usage

deployrExternal(file, isPublic = FALSE)

Arguments

file

Required. A character string specifying a valid filename with its extension.

isPublic

Optional. If isPublic = NULL or isPublic = FALSE and code is running on DeployR, then the file is assumed to be in your private user external directory. If isPublic = TRUE and code is running on DeployR, then the file is assumed to be in the public external directory. Since the usage of the public external directory is ultimately a deployment decision, please coordinate with the application developer(s) before enabling this argument.

Details

The deployrExternal function allows you access to file data portably by identifying the filename as an argument on the function call. The function then locates the file for you as follows:

  • In your local environment, the function looks for the data file in the current working directory for your local R session. In order for your R code to locate the local file with this function, make certain that a copy of the data file exists in your local working directory. Any references to the isPublic argument are ignored.

  • In your remote DeployR environment, the function locates the data file without requiring you to know the exact physical location of the file on the DeployR server. In order for your R code to find the file data, ask your DeployR administrator to physically store a copy in the external directory for you. The function looks in your private directory unless isPublic = TRUE, in which case it looks in the public external directory. Note: This function will not permit R code to write to files in the public external directory.

Important! If your R code fails on the DeployR server, ask your DeployR administrator to verify that the files you sent him or her were, in fact, deployed to the external directories.

Examples

## Not run: 

    ## READ CSV FILE
    ## Local: find in current working directory
    ## DeployR: find in user's external directory
    data <- read.csv(file = deployrExternal("data.csv"))

    ## READ CSV FILE
    ## Local: find in current working directory
    ## DeployR: find in public external directory
    data <- read.csv(file = deployrExternal("data.csv", isPublic = TRUE))

    ## READ XDF FILE FROM SCALER & STORE AS DATAFRAME (df)
    ## Local: find in current working directory
    ## DeployR: find in user's external directory
    df <- RxXdfData(deployrExternal("data.xdf"))

    ## WRITE TO CSV FILE 
    ## Local: write to current working directory
    ## DeployR: write to user's external directory
    write.csv(file = deployrExternal("data.csv"))

    ## WRITE TO XDF FILE FROM DATAFRAME
    ## Local: write to current working directory
    ## DeployR: write to user's external directory
    rxDataFrameToXdf(data = df, outFile = deployrExternal("data.xdf"), overwrite = TRUE)

## End(Not run)


deployr/deployrUtils documentation built on July 5, 2023, 9:58 a.m.