In your first example, I think R cannot find the tidy() function because it is part of the broom package and that package is not loaded as part of tidyverse. Try running
library(broom)
For you question about doing many tests, I would write a function to return the result of aov() and then use the map() function from purrr to iterate over a vector of protein names.
library(purrr)
library(dplyr)
DF <- data.frame(Protein = rep(c("A", "B"), each = 30),
Treatment = c(rep(c("T", "Placebo"), each = 15),rep(c("T", "Placebo"), each = 15) ),
Value = c(rnorm(15, 1, .3), rnorm(15, 1.4, .3), rnorm(15, 2, .3), rnorm(15, 2.2, .3)))
head(DF)
#> Protein Treatment Value
#> 1 A T 1.1328789
#> 2 A T 0.7137068
#> 3 A T 0.8887848
#> 4 A T 0.6592692
#> 5 A T 1.0194686
#> 6 A T 0.6457387
Proteins <- c("A", "B")
AOVfunc <- function(P) {
tmp <- filter(DF, Protein == P)
aov(Value ~ Treatment, data = tmp)
}
Tests <- map(Proteins, .f = AOVfunc)
map(Tests, summary)
#> [[1]]
#> Df Sum Sq Mean Sq F value Pr(>F)
#> Treatment 1 1.356 1.3560 20.68 9.55e-05 ***
#> Residuals 28 1.836 0.0656
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> [[2]]
#> Df Sum Sq Mean Sq F value Pr(>F)
#> Treatment 1 0.000 0.00000 0 0.998
#> Residuals 28 2.724 0.09727
Created on 2021-03-03 by the reprex package (v0.2.1)
Finally, the reprex cannot find an object called data but there is a function called data, so it tries to pass that to the filter() function and filter() does not know how to process a function. I suggest you do not call your data object data because of the existing function. If you had defined data within the reprex, it would have worked.