0

I understand this may be a rearranging issue on my end, but I just can't visualize how best to do this.

I can follow steps included in other normalize questions to use like here and here, but my issue is that my data (pasted a sample below) is recording various metrics of "variation". So SE, SD, etc. I am not interested in what they measured, nor am I interested in how the sites compare numerically. This latter point I do not know how to describe because my statistical knowledge is poor, what I mean is if Site 1 has values 1-10 and Site 2 has 11-20, I want to compare the distributions of variation among a different category (in sample below it is "Res", "Un", "Ref"). So I want to normalize the variable "score" below, but indivdually for each site.

I want to basically use scale(d) but add an argument similar to group = when making plots, to scale discrete groups within a column of variables.

I hope this makes sense and let me know if any additional information may be useful.

site score treatment
2 0.055 Un
2 0.055 Res
3 2 Res
3 3 Ref
3 1 Un
4 66 Res
4 0.6 Res
4 11 Un
sleepy
  • 93
  • 9
  • this is a bit hard to understand, can you provide a fake figure or results of what you are after? – Nakx Mar 21 '20 at 04:24
  • This should get you where you want to go, you cannot use regular scale because it will not vectorize, but using `tidyverse/dplyr` you can create your own grouped normalizers: https://stackoverflow.com/questions/43680246/normalize-by-group – sconfluentus Mar 21 '20 at 05:13
  • Do you want to group 1) by site or 2) by both site and treatment? – Rui Barradas Mar 21 '20 at 06:32
  • 1) `with(d, ave(score, site, FUN = scale))`; 2) `with(d, ave(score, site, treatment, FUN = scale))`. – Rui Barradas Mar 21 '20 at 06:36

0 Answers0