我当前使用gganimate印刷小提琴的代码如下
library(ggplot2); library(gganimate); library(ggpubr)
ggplot(dat2, aes(x=diet, y=bicep, fill=diet)) +
geom_violin() +
scale_fill_manual(values=c("#00AFBB", "#FC4E07")) +
stat_compare_means(aes(label = ..p.format..), paired = FALSE, label.x.npc = 0.5) +
labs(title = 'Week: {frame_time}') +
transition_time(time) +
ease_aes('linear')
此处打印出p值,但它们只是总体p值。我希望p值随时间(0、6和12周)变化。在我的研究中,每个结局测量值(二头肌)是在三个不同的时间(0、6和12周或时间1,时间2,时间3)进行的,如果我可以显示在时间0处变化的p值,那就太好了, 6、12。这里,我将使用不成对的t检验来比较饮食/治疗中的组均值。
或者,在两种饮食的“ 3”时的二头肌与“ 1”时的二头肌进行比较的最后,显示p值(配对t检验)。
我将如何去做?感谢您阅读本文。
数据结构
structure(list(code = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L,
4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L), diet = c("a",
"a", "a", "b", "b", "b", "a", "a", "a", "b", "b", "b", "a", "a",
"a", "b", "b", "b", "a", "a", "a", "b", "b", "b"), time = c(1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L), bicep = c(8L, 7L, 7L, 9L, 9L, 9L,
11L, 10L, 9L, 11L, 11L, 12L, 12L, 11L, 10L, 9L, 9L, 9L, 12L,
10L, 8L, 12L, 12L, 12L)), class = "data.frame", row.names = c(NA,
-24L))
可复制的加尼玛尼特码
ggplot(example3, aes(x=diet, y=bicep, fill=diet)) +
geom_violin() +
scale_fill_manual(values=c("#00AFBB", "#FC4E07")) +
stat_compare_means(aes(label = ..p.format..), paired = FALSE, label.x.npc = 0.5) +
labs(title = 'Week: {frame_time}') +
transition_time(time) +
ease_aes('linear')
答案 0 :(得分:0)
您可以尝试预先计算p。值。
var a_string = 'Some text <a href="mailto:mail@example.com">example 1</a></p> some <a href="www.example2.com"> example 2</a>text',
el = document.createElement('p');
el.innerHTML = a_string;
var a = el.querySelectorAll('a');
var texts = [].slice.call(a).map(function(val){
return val.innerHTML;
});
alert(texts);
// TODO ieterate and replace occurence n with texts[n]
您需要安装library(gganimate)
library(tidyverse)
example3 %>%
group_by(time) %>%
mutate(p=wilcox.test(bicep~diet, exact =F)$p.value,
max=max(bicep, na.rm = T)) %>%
ggplot() +
geom_violin(aes(x=diet, y=bicep, fill=diet)) +
geom_text(data = . %>% distinct(p, max, time),
aes(x=1.5, y = max+.5, label=as.character(round(p,2))),
size=12) +
transition_time(time) +
ease_aes('linear')