In the following example, we have a data frame dfSceneDur
with three variables,
sceneId
indicates the scenesblockId
marks the two conditions in this studydur
is the duration of each sceneWe wish to test if dur
differs by condition in each scene. Given the number of multiple
comparisons, we need to adjust the family significance level, e.g., using the Bonferroni method.
``` {r eval=FALSE}
wilcoxRes <- dfSceneDur %>% group_by(sceneId) %>% do(w = wilcox.test(as.numeric(.$dur) ~ .$blockId, data=.))
wilcoxRes.sig <- NULL for (i in 1:length(wilcoxRes$sceneId)) { # loop through all scenes scene<- wilcoxRes$sceneId[i] p<- wilcoxRes$w[i][[1]]$p.value if (p.adjust(p, n=length(wilcoxRes$sceneId), method="bonferroni")<0.05) { append(wilcoxRes.sig, paste("Test is significant (with Bonferroni adjustment) for Scence='", scene, "', with p=", p)) } }
In generating the report, we can do something like
There are r '\x60r length(wilcoxRes.sig) \x60'
scenes showing significant
difference after the Bonferroni adjustment:
r '\x60r print (wilcoxRes.sig) \x60'
```
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.