0

This is my current code:

library(rstatix)
library(dplyr)

lk %>%
  group_by(sample) %>%
  get_summary_stats(cd, type = "mean_sd")
lk %>% anova_test(cd ~ sample)

it prints the mean and 1 standard deviation, but I would like it to print 2 standard deviation instead. Apart from manually multiplying the 1 standard deviation, is there a way to code it? Cause I'm using this code multiple times.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Bloop
  • 43
  • 1
  • 6
  • 3
    Please [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including a small representative dataset in a plain text format - for example the output from `dput(lk)`, if that is not too large. Also include all the relevant code and packages: where do the functions `group_by`, `get_summary_stats` and `anova_test` come from? – neilfws Feb 08 '23 at 22:46

1 Answers1

3

You can calculate 2sd by adding mutate() function to your code after get_summary_stats() function:

library(tidyverse)
library(rstatix)

lk %>%
  group_by(sample) %>%
  get_summary_stats(cd, type = "mean_sd") %>%
  mutate(sd = 2 * sd) 

lk %>% anova_test(cd ~ sample)
zx8754
  • 52,746
  • 12
  • 114
  • 209
S-SHAAF
  • 1,863
  • 2
  • 5
  • 14