[R] how to use expression as function arguements?

casperyc casperyc at hotmail.co.uk
Sat Dec 18 20:34:44 CET 2010


Hi all,

#####################################
integ=function(f,n){ 
	# computes vector y = f(x)
	x=runif(10000)
	y=f
	hatI=mean(y)
	hatI
}
# example of use
integ(x^2+x+100,100)
#####################################
it returns an error says no obj 'x'

how do I 'tell' R to treat 'f' as an input expression?

Thanks.

casper
-- 
View this message in context: http://r.789695.n4.nabble.com/how-to-use-expression-as-function-arguements-tp3093940p3093940.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list