I'm trying to get used to the issues of defining a region in R. I would like to call the glm()
function inside the function, but it does not work, apparently for reasons that I could not fix with the assign()
or eval()
functions.
Here is a simplified version:
ao <- function (y, x, phi = seq (0,1,0.1), dataset, weights) { logLikvector <- rep(0,length(phi))
Now I want to use the ao () function in my dataset
ao (y = Prop, x = Age, dataset = mydata, weights = Total)
This does not work, but the following works:
ao (y = mydata$Prop, x = mydata$Age, dataset = mydata, weights = mydata$Total)
Does anyone know what to do?
Any help would be greatly appreciated !!!
Btw, here's how to replicate my problem with the dataset I'm using
library("MASS") data(menarche) mydata <- menarche mydata$Prop <- mydata$Menarche / mydata$Total