toJan.R

This emails a bunch of objects from R to one of my accounts.
language: R
license: GPL 2

Code for Snippet:

                
# This is fun.
 
# a<-matrix(1:20,4,5)
# b<-list(letters[1:5])
# toJan(a,b,eigen,where="apple")
 
# where you need the functions below. This
# illustrates variable number of arguments,
# deparse, substitute, pipe, switch, dump
 
# ==================================================
 
toJan<-function(...,where="stat") {
objs<-nameargs(...)
email<-switch(where,
       stat="[email protected]",
       fraz="[email protected]",
       apple="[email protected]",
       cuddy="[email protected]",
       ucla="[email protected]")
smoke<-pipe(paste("mail -s 'Voila some objects' ",email),"w")
dump(objs,smoke)
close(smoke)
}
 
## this one is taken from Venables and Ripley, p. 46
 
nameargs<-function(...) {
dots <- as.list(substitute(list(...)))[-1]
nm <- names(dots)
fixup <- if (is.null(nm)) seq(along = dots) else nm == ""
dep <- sapply(dots[fixup],function(x) deparse(x)[1])
if (is.null(nm)) return(dep) else { nm[fixup] <- dep; return(nm) }
}
 
comments powered by Disqus

Info

Source Site:

Jan

Tags: Pipes Email

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 223
Date Added: 2013-03-07 16:39:30
Last Modified: 2013-04-17 22:12:19

Web Analytics