Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a3b773
commit 89f091b
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Example R code to install packages | ||
# See http://cran.r-project.org/doc/manuals/R-admin.html#Installing-packages for details | ||
# | ||
|
||
########################################################### | ||
# Update this line with the R packages to install: | ||
|
||
my_packages = c("ggplot2") | ||
|
||
########################################################### | ||
|
||
install_if_missing = function(p) { | ||
if (p %in% rownames(installed.packages()) == FALSE) { | ||
install.packages(p, dependencies = TRUE) | ||
} | ||
else { | ||
cat(paste("Skipping already installed package:", p, "\n")) | ||
} | ||
} | ||
invisible(sapply(my_packages, install_if_missing)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
shopt -s extglob | ||
set -e | ||
|
||
stack=${1:-cedar} | ||
branch=${2:-cedar} | ||
|
||
dir=`mktemp -d` | ||
cp -r . $dir | ||
pushd $dir | ||
|
||
git init | ||
git add --all | ||
git commit -m "initial" | ||
|
||
heroku create --stack $stack \ | ||
--buildpack https://github.com/virtualstaticvoid/heroku-buildpack-r.git#$branch | ||
|
||
app=`heroku apps:info -s | grep ^name=` | ||
app=${app:5} | ||
|
||
git push heroku master | ||
|
||
# run R console | ||
heroku run "R --no-save -f ./prog.r" --app $app | ||
|
||
popd | ||
|
||
# clean up | ||
heroku apps:destroy $app --confirm $app | ||
rm -rf $dir |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Example R program | ||
# | ||
|
||
# example from http://www.cookbook-r.com/Graphs/Bar_and_line_graphs_(ggplot2)/ | ||
|
||
library(ggplot2) | ||
|
||
dataframe <- data.frame(time=factor(c("Lunch", "Dinner"), levels = c("Lunch", "Dinner")), total_bill = c(14.89, 17.23)) | ||
|
||
plot = ggplot(data=dataframe, aes(x=time, y=total_bill)) + geom_bar(stat="identity") | ||
|
||
filename <- tempfile(fileext='.png') | ||
|
||
ggsave(filename=filename, height=5, width=15, type="cairo", plot) | ||
|
||
# TODO: store output file somewhere persistent. E.g. S3 | ||
|
||
print(filename) |