I tried with a more complex example, more representative of my data but I do not really understand why it does not work. It always makes result equal to zero.
Is it because I group my samples in order to determine the mean for each group?
> Rstudio_Examples <- read_excel("Desktop/Rstudio-Examples.xlsx")
> View(Rstudio_Examples)
> Enzyme <- Rstudio_Examples
> head(Enzyme, 8)[, c('Sample', '24H')]
# A tibble: 8 x 2
Sample `24H`
<chr> <dbl>
1 Blank 0.033
2 Blank 0.035
3 ProtA 0.201
4 ProtA 0.188
5 ProtB 0.345
6 ProtB 0.321
7 ProtC 0.245
8 ProtC 0.222
> datapasta::df_paste(head(Enzyme, 8)[, c('Sample', '24H')])
> data.frame(
+ stringsAsFactors = FALSE,
+ check.names = FALSE,
+ Sample = c("Blank","Blank","ProtA",
+ "ProtA","ProtB","ProtB","ProtC","ProtC"),
+ `24H` = c(0.033, 0.035, 0.201, 0.188, 0.345, 0.321, 0.245, 0.222)
+ )
Sample 24H
1 Blank 0.033
2 Blank 0.035
3 ProtA 0.201
4 ProtA 0.188
5 ProtB 0.345
6 ProtB 0.321
7 ProtC 0.245
8 ProtC 0.222
> Enzymes_24H <- Enzyme %>% group_by(Sample) %>% summarize(Mean = mean(`24H`))
> View(Enzymes_24H)
> Enzymes_24H <- Enzymes_24H %>% rename("24H" = "Mean")
> View(Enzymes_24H)
> Enzymes_24H$ActivityAdj <- Enzymes_24H$"24H" - Enzymes_24H[1,2]
> View(Enzymes_24H)
> head(Enzymes_24H, 4)[, c('Sample', '24H', 'ActivityAdj')]
# A tibble: 4 x 3
Sample `24H` ActivityAdj$`24H`
<chr> <dbl> <dbl>
1 Blank 0.034 0
2 ProtA 0.194 0
3 ProtB 0.333 0
4 ProtC 0.233 0
>
Thank you in advance.