-
-
Save hubte1g/0f9eade763188281ae67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download: http://tap.tibco.com/ -> "Samples" tab -> RinR -> "Try Now" button | |
# Docs: http://docs.tibco.com/pub/enterprise-runtime-for-R/2.5.0/doc/html/RinR/RinR-package.html | |
######################################## | |
# Setup | |
######################################## | |
library(RinR) | |
library(Sdatasets) | |
######################################## | |
# Tell TERR where to find R | |
######################################## | |
# Option 1 - Explicit & Temporary | |
RinR::pushPATH("c:/Program Files/R/R-3.1.1/bin") | |
# Option 2 - Explicit & Permanent | |
# | |
# Modify /engine/etc/TERRprofile.site | |
# Add: options(RinR_R_FULL_PATH = "c:/Program Files/R/R-3.1.1/bin") | |
# Option 3 - Do nothing! | |
# | |
# TERR will search the PATH and pick the first engine it finds | |
######################################### | |
# Show which engine is used | |
######################################### | |
REvaluate(version$version.string, REvaluator) | |
######################################### | |
# Run a computation | |
######################################### | |
# Method 1 - Direct | |
x <- 1:100 | |
val <- REvaluate(sum(x), REvaluator, data = c("x")) # val == 5050 | |
# Method 2 - Via Parameter Input (i.e. string passed into Spotfire data function) | |
rcode <- "x <- 1:100; sum(x)" | |
val <- REvaluate(eval(parse(text = rcode)), REvaluator, data = c("rcode")) # val == 5050 | |
######################################### | |
# Return a graph | |
######################################### | |
# base | |
myplot <- RGraph(hist(fuel.frame$Weight), | |
data = "fuel.frame", | |
display = TRUE) | |
# lattice (need explicit 'print') | |
myplot <- RGraph(print(xyplot(Fuel ~ Weight | Type, data=fuel.frame)), | |
packages="lattice", | |
data = "fuel.frame", | |
display = FALSE) | |
# ggplot2 (need explicit 'print') | |
myplot <- RGraph(print(qplot(x = Fuel, geom = "histogram", data = fuel.frame)), | |
packages="ggplot2", | |
data = "fuel.frame", | |
display = TRUE) | |
######################################### | |
# Get graph into Spotfire | |
######################################### | |
# 1. just set 'myplot' as an output from the script | |
# 2. assign that output to a 'binary' label in a text area | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment