[R] par mfrow in "function" problem

casperyc casperyc at hotmail.co.uk
Wed Nov 10 20:31:03 CET 2010


Hi all,

I defined the following

#############################
myhist=function(x){
	hist(x,xlab="",main="")
	h=hist(x)
	xfit=seq(min(x),max(x),length=100)
	yfit=dnorm(xfit,mean(x),sd=sd(x))
	yfit=yfit*diff(h$mids[1:2])*length(x)
	lines(xfit, yfit, col="blue", lwd=2)
}
#############################

individually, it worked fine

however, if I used

par(mfrow=c(2,2))

each time i run myhist

it produces TWO plots,

one without the 'lines',
and one with the 'lines'

why is that??

Thanks.

casper
-- 
View this message in context: http://r.789695.n4.nabble.com/par-mfrow-in-function-problem-tp3036745p3036745.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list