Skip to content

Run function several times changing only one argument - without a loop

5 messages · Enrico Schumann, Eik Vettorazzi, Marion Wenty +1 more

#
Hi Marion,

is all you want the white vertical lines? Then try

abline(v = seq(10, 90, by = 10), col = "white")

instead of your axis commands.


Regards,
Enrico

Am 20.02.2012 11:04, schrieb Marion Wenty:

  
    
#
Hi Marion,
you can either use any of the *apply-functions or vectorize your
function (which internally uses mapply):

par(las=1)
par(mar=c(5,13,4,2))
barplot(Ee1,horiz=T,col="grey85",border="NA",xlim=c(0,100),axes=F)

#using sapply
invisible(sapply((1:9)*10,function(x)axis(2,pos=x,tick=T, tcl=F,
labels=F,col="white")))

#using Vectorize
barplot(Ee1,horiz=T,col="grey85",border="NA",xlim=c(0,100),axes=F)
vaxis<-Vectorize(axis,"pos")
invisible(vaxis(2,pos=(1:9)*10, tick=T, tcl=F, labels=F,col="white"))

Cheers!

Am 20.02.2012 11:04, schrieb Marion Wenty:

  
    
#
On Feb 20, 2012, at 5:04 AM, Marion Wenty wrote:

            
See if grid() is helpful:

barplot(Ee1,horiz=T,col="grey85",border="NA",xlim=c(0,100),axes=F)
grid(nx=9, ny=NA, col="white")

Somehow using axis to draw elements inside a graph seems "wrong",  
especially when you are using it for what is basically  side-effect as  
you have been attempting. Could also have used abline which accepts a  
vector for its v argument.

 > barplot(Ee1,horiz=T,col="grey85",border="NA",xlim=c(0,100),axes=F)
 > abline(v=seq(10,90,by=10), col="white")
A large number of functions will offer that facility using seq() as  
the functional input argument.
You might consider working in the settings for your mail client. I  
know that gmail offers that option.