## Wednesday, January 23, 2013

So for a conservation-oriented project I'm working on I wrote an R package to implement arbitrary-stage and currently 1-D integral projection models (IPM's)[1].  It lets you define and simulate from an IPM using a few data frames and R's formula interface to define the projection kernels[2].  It's been a great time-saver for me since I finished up most of it... but I'm still very suspicious of the code quality so when I got an error message I immediately blamed the package code...


> pop\$step()
Error in model_matrix(newdata, covariates, n) :
Model matrix columns for some coefficients missing:
Missing columns for:
sizes

... of course I had just happened include a coefficient which I did not use in the R formula for the model matrix ( ~ 1, where ~ 1 + sizes would have worked)... so I get to learn, once again, the age-old dictum of writing code: _read_ the error messages.  Really.  READ them. Especially if you went through the trouble of writing good ones.

[1] Ellner and Rees 2006 being the best starting reference for those....
[2] It'll be on CRAN someday...