[R] passing arguments to simple plotting program.

Gerard Smits smits.gerard.j at gmail.com
Tue May 9 00:48:11 CEST 2017


Hi All,

I thought I’d try to get a function working instead of block copying code and editing. My backorund is more SAS, so using a SAS Macro would be easy, but not so lucky with R functions.


R being used on Mac Sierra 10.12.4:

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)


resp<-read.csv("//users//gerard//gs//r_work//xyz.csv", header = TRUE)

v5  <-subset(resp, subset=visit==5 & pp==1)

plot_f1 <-function(n1,n2,n3) {
  attach(v8)
  par(oma=c(2,2,2,2))
  boxplot(formula = d_comp ~ rx_grp, 
          main="Figure 2\nChange in Composite Score at Visit 5 (Day 31)\nPer Protocol Population",
          ylim=c(-10,5),
          names=c('Placebo(N=n1)  ',
    	          'Low Dose(N=n2) ',
  		  'High Dose(N=n3)'),
          ylab='Change from Baseline')
  abline(h=c(0), col="lightgray")
}

plot_f1(n1=114, n2=119, n3=116)

The above is a simplified example where I am trying to pass 3 arguments, n1-n3, to be shown in the x-axis tables,  Instead of the numbers, I get the literal n1, n2, n3.

Any help appreciated.

Thanks,

Gerard




	[[alternative HTML version deleted]]



More information about the R-help mailing list