Thomas W Blackwell <[EMAIL PROTECTED]> writes: > Ed - > > You seem to have encountered a bug. I can reproduce Ed's difficulty > in a completely artificial example in which there are unused levels : > > tmp <- factor(rep(seq(10), seq(10))) # length(tmp) # [1] 55 > ave(seq(50), tmp[-seq(5)]) # gives NA in rows 32-50 > > I would consider this to be incorrect behavior for the function > ave(). For the base package maintainers, I would suggest modifying > the definition of ave() so that the line involving as.factor() > reads : > > l[[i]] <- li <- as.factor(l[[i]][,drop=T]) .
A minimal version of the same effect would be > ave(1:2,factor(2:3,levels=1:3)) [1] 2 NA Your fix looks sensible to me, but it might be better with simply > l[[i]] <- li <- factor(l[[i]]) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
