I am trying to create a function where a user inputs any function, ie x^2, sin(x) ect, and my function needs to estimate the any under the graph using monte carlo methods. So far I have this (see below), but when i put in the console mcArea(f^2) it says object f not found. I know that later I need to implement integration to calculate the area but to start with I'm a bit stuck. I'm new to programming :))

any help would be fab !

mcArea <- function(f, n=100) {

a <- runif(n)

b <- runif(n)

I <- ifelse((f) < 1, TRUE, FALSE) * 1

}