[R] Calling Function With Arguments In a Script
Clint Bowman
clint at ecy.wa.gov
Thu May 7 23:16:07 CEST 2015
?source
as in source("pairwise-plots-continuous-vars.R")
then
plotpairs(first,second,third,wise,title)
should get you going
Clint Bowman INTERNET: clint at ecy.wa.gov
Air Quality Modeler INTERNET: clint at math.utah.edu
Department of Ecology VOICE: (360) 407-6815
PO Box 47600 FAX: (360) 407-7534
Olympia, WA 98504-7600
USPS: PO Box 47600, Olympia, WA 98504-7600
Parcels: 300 Desmond Drive, Lacey, WA 98503-1274
On Thu, 7 May 2015, Rich Shepard wrote:
> I'm starting to put code in multi-use functions rather than in individual
> scripts and have not learned how to invoke the function from the command
> line. If this information is in Norman Matloff's 'The Art of R Programming'
> or Hadley Wickham's 'Advanced R' please point me to the proper place.
>
> Here's an example, the script 'pairwise-plots-continuous-vars.R' consists
> of this function:
>
> plotpairs <- function(x1,x2,x3,y,plotmain) {
> require(compositions)
> opar <- par(mar=c(4,4,3,1))
> NO3 <- x1
> SO4 <- x2
> pH <- x3
> pairwisePlot(cbind(NO3,SO4,pH),clr(y),add.line=T)
> title(main=plotmain)
> par(opar)
> detach('package:compositions')
> return()
> }
>
> (I suppose the return statement is superfluous since there is no value
> returned to a calling function.)
>
> What I want to do is call plotpairs() with appropriate arguments for each
> plot as needed.
>
> TIA,
>
> Rich
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list