Code Monkey home page Code Monkey logo

deployrutils's Introduction

deployrUtils - Develop Portable R Code for Use with DeployR

Build Status

Package Overview

The goal of deployrUtils is to solve several R portability issues that arise when developing R analytics for use in your local R environment and in the DeployR server environment. They are package portability, input portability, and portable access to data files.

These portability issues can be solved when you use the following functions in the deployrUtils package.

  • Use the deployrPackage function to declare your package dependencies in your R code.
  • Use the deployrInput function to declare the required inputs along with default values in your R code.
  • Use the deployrExternal function to access big data files from your R code.

Package Installation

Get the latest stable development version from github:

# Use `devtools` to install directly from github
library(devtools)
install_github("Microsoft/deployrUtils")

See devtools for more options.

Usage

Install and load R packages to ensure package portability:

# Use `deployrPackage()` to ensure package dependencies are installed & loaded 
# at the start of your script.
> deployrPackage("ggplot2")
Loading required package: ggplot2
...
...
...
Loading required package: ggplot2
> ?ggplot2

Declare inputs to ensure R script input portability:

# Creates a `character` variable named `char` if it does not exist
> deployrInput('{ "name": "balance", "render": "integer", "default": "500" } ')
> balance
[1] 500

Access big data files in a portable way across environments:

## Referencing a CSV data file in your external directory
data <- read.csv(file = deployrExternal("data.csv")) 

## Referencing an XDF data file in your external directory
df <- RxXdfData(deployrExternal("data.xdf"))

More Information

Issues:

Post an issue

Website:

Learn more

Made by:

Microsoft Corporation

deployrutils's People

Contributors

j-martens avatar microsoft-github-policy-service[bot] avatar swells avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deployrutils's Issues

deployr.com

Hey there, couldn't find any other contact info, so thought I'd place this here.

I own deployr.com, wondering if you guys are interested in purchasing it?

Please contact me privately at steve at slantview dot com.

Thanks.

deployrInput support for render list

When i specifiy render:"list" in deployR script
Invalid render value deployrInput('{ "name": "scores", "label": "scores", "render": "list", "default":[]}')

what's the best way to return results of an R script with deployR?

I'm writing an R Script to be used in deployR.

For example my script could be something like this:

deployrInput('{"name": "x", "render": "integer", "default": 6}')
deployrInput('{"name": "y", "render": "integer", "default": 6}')
results <- x*y
results

I wan't my call to the API to return the results object.
The best way is to catch the results object with the call?

deployr.io('/r/repository/script/execute')   
   .data({ filename: 'filename.R', author: 'daniel'})
   .numeric('x', 6)
   .numeric('y', 5)
   .routput('results')
   .end(function(res) {
     a = res.deployr.response.workspace.objects[0];
     console.log(a.value);
});

I don't like this way because I will always have to tell the application developpers which is the value they have to catch from my script.

I would like to be able to just return a value that could be acessed with res.deployr.response.value, or any standard way..

Publish to CRAN to help with DeployR builds

Both DeployR Windows/Linux builds need to pull from Github and/or CRAN for the package latests and not depend on hardcoded version numbers. This makes it easier to iterate changes on deployrUtils without having to wait for a new DeployR server build to get fixes/changes to this package out.

deployrInput ignores existing variable value if default value is provided

Current code in deployrInput.R line 100 only uses the existing value when it exists AND default value is not provided. As a result, script is unable to get input value from API request when a default value is provided in deployrInput declaration.

# if "name" variable exists, use it instead of default
  if (!is.null(name)) {
    if (exists(name) && is.null(default)) {
      x <- get(name)  
    } else if (exists(name)) {
      return
    } 
  }

deployrInput ignores existing variable value if the variable name happens to be "x"

Symptom: deployrInput ignores existing variable value (and thus API input) if the input variable name happens to be x.

Cause: line 104 reads the existing variable value using x <- get(name), but if name happens to be "x", then this line would actually read the x value assigned in line 96 (i.e. the default value).

Possible solution: default value should only be used when the variable value is not provided by input.

    if (!is.null(name) && exists(name)) {
        x <- get(name)  
    } else {
        if (!is.null(default)) {
            x <- default
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.