"Error in eval(predvars, data, env) : object not found" when running my code in a function

(exdf <- data.frame(x=1:3,
                   y=2:4))

lm(y~x,data = exdf)

#will fail with
#Error in eval(predvars, data, env) : object 'x' not found
myfunc <- function(v){
  lm(y~v,data = exdf)
}
myfunc(x)

#convenient to make the formula as a string
myfunc <- function(vc){

  lm(as.formula(paste0("y~",vc)),
     data = exdf)
}
myfunc("x")