0

I am trying to run t-tests on my data using the following code:

stat.test <- mydata.long %>%
  group_by(cytokines) %>% 
  t_test((value ~ Rx)) %>%
  adjust_pvalue(method = "bonferroni") %>%
  add_significance()
stat.test

My data frame looks like this:

mydata.long %>% sample_n(6)
# A tibble: 6 x 4
  Rat_ID Rx     cytokines         value
   <dbl> <chr>  <chr>             <dbl>
1    459 Met8wk Hepassocin       12.2  
2    480 AdLib  basicFGF         -0.371
3    434 AdLib  PositiveControl  14.8  
4    578 Met8wk Osteopontin.SPP1  0.249
5    457 Met8wk TRAIL            11.7  
6    523 AdLib  Osteopontin.SPP1  3.12 

There are about 90 different cytokines and I have a treated and untreated "Rx" column. When I run the t_test code I get the following error:

> mydata.long %>%
+   group_by(cytokines) %>% 
+   t_test((value ~ Rx)) 
Error: Problem with `mutate()` input `data`.
x data are essentially constant
i Input `data` is `map(.data$data, .f, ...)`.

Any advice on how to fix this issue?

KCS
  • 67
  • 3

1 Answers1

1

I updated your code assuming independent sample t-test. Hope this is what you are looking for:

library(tidyverse);library(rstatix)

mytest <- mydata.long %>% group_by(cytokines) %>% nest() %>% 
mutate(
ttest=map(data,~ t_test(value ~ Rx, paired=F,data = .x))) %>%
      adjust_pvalue(method = "bonferroni") %>%
      add_significance()

mytest$ttest
S-SHAAF
  • 1,863
  • 2
  • 5
  • 14