Hi All,

I have a for loop inside the function and I cannot get UUU to give me an updated grid.dens object when I run the function (it does update when I run just the for loop). Here's a simplified version of my function:

UUU=function(pop, grid.dens) {

for (i in 1:10){
Food=grid.dens[pop$yloc[i],pop$xloc[i]]   #use initial grid.dens values
Consumed=(pop$weight[i]*0.25)
Left=Food-Consumed
grid.dens[pop$yloc[i],pop$xloc[i]]=Left   #update grid.dens values on i
pop$birth[i]=pop$birth[i]+1
}
return(pop)
return(grid.dens)
}

I get an updated pop, but not an updated grid.dens.  What am I doing wrong?

Thanks!

Nico

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to