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

Enrico Schumann enricoschumann at yahoo.de
Mon Feb 20 11:35:18 CET 2012


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:
> Dear people,
>
> I created a plot which looks like this:
>
> Ee1<-matrix(c(88,86,74,62,41),ncol=5)
> colnames(Ee1)<-c("Lehrer","Lehrerinnen","Klassenkollegen","Klassenkolleginnen","Geschwister")
> par(las=1)
> par(mar=c(5,13,4,2))
> barplot(Ee1,horiz=T,col="grey85",border="NA",xlim=c(0,100),axes=F)
> axis(2,pos=10, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=20, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=30, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=40, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=50, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=60, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=70, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=80, tick=T, tcl=F, labels=F,col="white")
> axis(2,pos=90, tick=T, tcl=F, labels=F,col="white")
>
> Now I would like to shorten the whole thing - namely use only one step to
> create the 9 axes without having to use a loop.
>
> In general, I would be interested if there is a way to use a function
> several times changing only one argument, without having to use a loop.
>
> Does anyone know how to do that.
>
> Marion
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>

-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net/



More information about the R-help mailing list