Hi all, I would like to normalize data base on one specific row value, the idea is to normalize the data
Example data
dfex <- data.frame(group = c("1","1","1","2","2","2","3","3","3"),
treat = rep(c("A","B", "C"), 3),
hight = rnorm(9),
weight = rnorm(9),
BMI = rnorm(9))
Now I would like to perform some operations and comparisons, and I have an internal control for the experiment in each group that is my treatment "A", so I found that the nicest way to scale is doing:
dfex %>%
mutate(val1 = hight/weight) %>%
group_by(group) %>%
mutate(val2 = scale(val1))
However what I need is to divide in each group my val2 = (val1 / val1(from treat="A")), because a hand calculations shows me that it makes a difference in the posterior statistical analysis.
I am following different R tutorials, but I do not manage to call that value properly.
If someone could help me with that and a link with a tutorial or something like that to understand the base of "it" (not sure which is the base I need for the answer), I would really appreciate it.