> What are the values of > > length((Ht_cm[type=='SD'][from_treeline=='above'])[1]) I suspect the error is in the subsetting - the following seems more plausible: Ht_cm[type=='SD' && from_treeline=='above'] Hadley -- http://had.co.nz/