@FJCC
Hi again FJCC,
I've been spending some time trying to apply a previous solution you helped me with (here in this thread) to additionally performing a t-test (in addition to taking means).
So, if I have a data frame like this:
mydf <- data.frame("replicate"=c("R1","R2","R3","R1","R2","R3","R1","R2","R3","R1","R2","R3","R1","R2","R3","R1","R2","R3"),
"variables"=c(1,1.1,2,10,11,10.1,100,100.1,100.2,2,2.1,2.2,11,11.1,11.2,500,500.5,500.1),
"mu"=c(1,1,1,10,10,10,100,100,100,2,2,2,11,11,11,5,5,5))
There are groups of 3 just like last time. For the first group of 3, the t.test code would be
t.test(c(1.0,1.1,2.0), mu=1
But I want to apply it using something similar to how you previously showed me how to get averages by these groups. The trouble is - I can't seem to easily swap out mean for t.test
#Trying to add a p-value
GroupLabels <- 0:(nrow(mydf) - 1)%/% 3
mydf$Group <- GroupLabels
pval <- mydf %>% group_by(Group) %>% summarize(pval = t.test(variables, mu=mu))
mydf <- inner_join(mydf, pval, by = "Group") %>%
select(-Group)
I get this:
Error: Problem with `summarise()` input `pval`.
x 'mu' must be a single number
i Input `pval` is `t.test(variables, mu = mu)`.
i The error occurred in group 1: Group = 0.
Run `rlang::last_error()` to see where the error occurred.
Do I need to group these differently?