Greg Snow wrote:
> Here is another approach using transform and ave which I think is a
> little simpler than the others suggested:
>
>   
>> new.data <- transform( iris, 
>>     
> +   normSW = Sepal.Width / ave(Sepal.Width, Species, FUN=max),
> +   normSL = Sepal.Length / ave(Sepal.Length, Species, FUN=max)
> +  )
>
> You can adjust it for your data.  Hope this helps,
>
>   
Yes, I was about to suggest the same. Or

...ave(Sepal.Width, Species, FUN = function(x) x/max(x))..

Should we have a competition for a more evocative name than "ave"?

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])                  FAX: (+45) 35327907

______________________________________________
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.

Reply via email to