I have DF which looks like
DF
Nrow a b c d
1 0.1 0.2 0.3 0.4
2 2 3 4 5
3 7 8 9 10
I want to subtract row 1 from row 2 and row 3.
How can i do it ? Thank you for any tips.
Updates
I saw this code: within-group differences from group member, and tried it as well.
Edited my data:
newdf <- df[!is.na(S[,1]),]
## df had NA values which was interfering with analysis, so I removed them.
df <- data.frame(treatment = rep(c('','baseline', 'treatment 1', 'treatment 2'), times=372),S[c(1:258)])
A <- df %>%
mutate_each(funs(. - .[treatment=="baseline"]), -treatment) %>%
filter(treatment!="baseline")
##have multiple columns for which I would like to calculate row-wise change
View(A)
However, now I thought to get correct results (or absolute change, i.e. row 2 - row 1), but the values are different from what I can calculate manually. Any thoughts?
Thanks!
Answers 11.03.2016
2-y Axes Plot with calculated absolute & relative Change in R