[R] passing "..." arguments to (plot.ca)

Duncan Murdoch murdoch.duncan at gmail.com
Sun Jan 22 21:46:26 CET 2012


On 12-01-22 3:23 PM, Ian Robertson wrote:
> I am hoping someone can give me a couple of pointers on how to pass
> arguments using "..."--in this specific case in an attempt to plot an
> object created by ca(), a tool for correspondence analysis.
>
> #some illustrative code
> library(ca)
> set.seed(123)
> dat1<- data.frame(matrix(ceiling(runif(30, 1, 100)), nc=5)) #some fake data
> ca1<- ca(dat1) #the correspondence analysis
> plot(ca1) #basic symmetric plot
> plot(ca1, ylim=c(-.4, .5), cex=2, xlab="CA Axis 1") #failed attempt to
> control various "extra" parameters
>     title(xlab="CA Axis 1") #this gets me access to xlabels...
> ?plot.ca #help!
>
> The last line suggests that "..." can be used to pass on arguments to
> plot (and points), but I can't seem to make it work. I have in the past
> been able to pass arguments to various tools (such plotting tools in the
> lattice library) using list(), but I can't get anything similar to work
> in this case. I have done some searching in the help archives (and
> various of my R books) without identifying anything helpful--so any
> suggestions for specific code I might try, or things I need to go read,
> etc., would be much appreciated.
>

Reading the source to plot.ca will help.  You can get it from the source 
to the ca package, or get a deparsed version as ca:::plot.ca. There I 
see that it passes ... to plot(), but it forces the xlab, ylab, and asp 
parameters to specific values.  (The labels are blanks, so using title 
is a viable solution.)

The cex argument is not used by plot, it is used by points(), and 
plot.ca gets the value from local variables cex.x and cex.y.  So you are 
probably out of luck in that case, other than asking the maintainer to 
modify the function, or modifying it yourself.  (You'd get a copy using

plot.ca <- ca:::plot.ca

then could use fix() to edit it.  R will use yours in preference to the 
original if you call it from the top level, but functions in the ca 
package will continue to see the original one first.)

Duncan Murdoch



More information about the R-help mailing list