On Wed, 2009-08-26 at 08:06 -0700, Phil Spector wrote:
> The ave function is very handy for things like this:
>
> mins = ave(D$Var,D$Site,FUN=function(x)min(x[x>0],na.rm=TRUE))
> D$Var = ifelse(is.na(D$Var) | D$Var == 0,mins,D$Var)
>
> should do the required replacements.
Thanks Phil, that's gre
The ave function is very handy for things like this:
mins = ave(D$Var,D$Site,FUN=function(x)min(x[x>0],na.rm=TRUE))
D$Var = ifelse(is.na(D$Var) | D$Var == 0,mins,D$Var)
should do the required replacements.
- Phil Spector
2 matches
Mail list logo