emorway wrote:
The following line of code seems fairly straight forward, yet it is kicking
back an error message:
for (i in
1:length(mean.natveg.frac)){month.observed[i]=as.numeric(names(mean.natveg.frac[i]))%%12}
Error message:
Error in month.observed[i] = as numeric(names(mean.natveg.frac[i]))%%12 :
object 'month.observed' not found
Seems like its not found because I'm trying to define it. Also
length(mean.natveg.frac) = 103
You can't index the object before it is defined. You can assign to
non-existent elements of an object, but it is very inefficient. So the
best fix is to put the line
month.observed <- numeric(length(mean.natveg.frac))
before the for loop.
Duncan Murdoch
______________________________________________
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.