Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Turning tabular into an S3 method for cast_df

And also adding the source_https.r file (just in case...)
  • Loading branch information...
commit 50a4efb96a61d80f28f332137f5da922cd9a7524 1 parent 6cd612f
@talgalili authored
Showing with 52 additions and 0 deletions.
  1. +23 −0 source_https.r
  2. +23 −0 source_https.r.txt
  3. +6 −0 tabular.cast_df.r
View
23 source_https.r
@@ -0,0 +1,23 @@
+# Filename: source_https.R
+# Purpose: function to source raw code from github project
+# Author: Tony Bryal
+# Date: 2011-12-10
+# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
+ # First found on:
+ # http://www.r-bloggers.com/source_https-sourcing-an-r-script-from-github-over-https/
+
+source_https <- function(u, unlink.tmp.certs = FALSE) {
+ # load package
+ require(RCurl)
+
+ # read script lines from website using a security certificate
+ if(!file.exists("cacert.pem")) download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile = "cacert.pem")
+ script <- getURL(u, followlocation = TRUE, cainfo = "cacert.pem")
+ if(unlink.tmp.certs) unlink("cacert.pem")
+
+ # parase lines and evealuate in the global environement
+ eval(parse(text = script), envir= .GlobalEnv)
+}
+
+# example:
+# source_https("https://raw.github.com/talgalili/R-code-snippets/master/tabular.cast_df.r")
View
23 source_https.r.txt
@@ -0,0 +1,23 @@
+# Filename: source_https.R
+# Purpose: function to source raw code from github project
+# Author: Tony Bryal
+# Date: 2011-12-10
+# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
+ # First found on:
+ # http://www.r-bloggers.com/source_https-sourcing-an-r-script-from-github-over-https/
+
+source_https <- function(u, unlink.tmp.certs = FALSE) {
+ # load package
+ require(RCurl)
+
+ # read script lines from website using a security certificate
+ if(!file.exists("cacert.pem")) download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile = "cacert.pem")
+ script <- getURL(u, followlocation = TRUE, cainfo = "cacert.pem")
+ if(unlink.tmp.certs) unlink("cacert.pem")
+
+ # parase lines and evealuate in the global environement
+ eval(parse(text = script), envir= .GlobalEnv)
+}
+
+# example:
+# source_https("https://raw.github.com/talgalili/R-code-snippets/master/tabular.cast_df.r")
View
6 tabular.cast_df.r
@@ -1,3 +1,9 @@
+# adding an an S3 method to tabular ...
+tabular <- function(...) UseMethod("tabular")
+tabular.default <- tables::tabular
+
+# This was tested on "tables" Version: 0.5
+
tabular.cast_df <- function(xx,...)
{
# a bunch of assumptions that must be met for this function to work:
Please sign in to comment.
Something went wrong with that request. Please try again.