0

I am successful in bootstrapping my data set but I am having trouble iterating the output of the function.

here is my code:

anova_one_run = function () {

  size_n = dim(dat)[1]
  dat_boot <- sample_n(dat, size_n, replace = TRUE)    #random sample with replacement
  dim(dat_boot)

anova_out <- aov(outcome ~ var1*var2 + (1/(id)), data = dat_boot)
anova_out=TukeyHSD(anova_out)


#iterate bootstrap; here is the issue... 
anova_simulate = as.data.frame(t(replicate(100, anova_one_run)))

When I iterate the data I get the function 100 times but not the output. I am looking to get 100 different outputs, i.e. the output for 100 random bootstrap samples with replacement.

zerz
  • 160
  • 1
  • 10
Alex
  • 3
  • 1
  • 1
    something is not good with your code, your function does not have a closing bracket ```}```. The function should also return something if you want to get a result – zerz Jun 08 '21 at 19:22
  • 1
    Hi. Please use a [minimal reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) example and wrap your code 3 backticks like in r markdown. – zimia Jun 08 '21 at 19:24
  • `replicate(100, anova_one_run())` <- you need to actually call the function with parentheses. – slamballais Jun 09 '21 at 10:34
  • Thanks everyone! slamballais the bracket worked thank you!! – Alex Jun 09 '21 at 13:34

0 Answers0