|
@ -10,11 +10,11 @@ ggstats_add_xy<-function(table_stat, table, xcol=NULL, group, y="max", bracket.o |
|
|
if (is.null(exclude_group)){ |
|
|
if (is.null(exclude_group)){ |
|
|
table_agg<-table %>% group_by(.data[[x]]) |
|
|
table_agg<-table %>% group_by(.data[[x]]) |
|
|
}else{ |
|
|
}else{ |
|
|
table_agg<-table %>% group_by(.data[[x]], .data[[exclude_group]]) |
|
|
|
|
|
|
|
|
table_agg<-table %>% group_by(.data[[x]], !!!syms(exclude_group)) |
|
|
} |
|
|
} |
|
|
if (y == "max"){ |
|
|
if (y == "max"){ |
|
|
agg<-table_agg %>% summarise(max=max(.data[[value.var]], na.rm = T)) |
|
|
agg<-table_agg %>% summarise(max=max(.data[[value.var]], na.rm = T)) |
|
|
if(!is.null(exclude_group)){agg<-table_agg %>% group_by(.data[[exclude_group]]) %>% summarise(max=max(.data[[value.var]], na.rm=T))} |
|
|
|
|
|
|
|
|
if(!is.null(exclude_group)){agg<-table_agg %>% group_by(!!!syms(exclude_group)) %>% summarise(max=max(.data[[value.var]], na.rm=T))} |
|
|
}else if (y == "mean"){ |
|
|
}else if (y == "mean"){ |
|
|
agg<-table %>% group_by(.data[[x]],.data[[group]]) %>% summarise(mean=mean(.data[[value.var]], na.rm=T)) %>% spread(group, mean) |
|
|
agg<-table %>% group_by(.data[[x]],.data[[group]]) %>% summarise(mean=mean(.data[[value.var]], na.rm=T)) %>% spread(group, mean) |
|
|
agg<- data.frame(x=agg[,1], "max"=apply(agg[,2:ncol(agg)], 1, max, na.rm=T)) |
|
|
agg<- data.frame(x=agg[,1], "max"=apply(agg[,2:ncol(agg)], 1, max, na.rm=T)) |
|
@ -55,7 +55,7 @@ ggstats_add_xy<-function(table_stat, table, xcol=NULL, group, y="max", bracket.o |
|
|
if (!is.null(exclude_group)){ |
|
|
if (!is.null(exclude_group)){ |
|
|
for (j in unique(pull(table_stat, all_of(exclude_group)))){ |
|
|
for (j in unique(pull(table_stat, all_of(exclude_group)))){ |
|
|
for (dia in unique(pull(table_stat,all_of(xcol)))){ |
|
|
for (dia in unique(pull(table_stat,all_of(xcol)))){ |
|
|
if (table_stat %>% filter(p < 0.05) %>% filter(.data[[x]] == dia & .data[[exclude_group]] == j) %>% nrow() > 0){ |
|
|
|
|
|
|
|
|
if (table_stat %>% filter(p < 0.05) %>% filter(.data[[x]] == dia & !!!syms(exclude_group) == j) %>% nrow() > 0){ |
|
|
t[table_stat[,x] == dia & table_stat[,exclude_group] == j,"y.position"]<-seq(t[table_stat[,x] == dia & table_stat[,exclude_group] == j,"y.position"][[1,1]], |
|
|
t[table_stat[,x] == dia & table_stat[,exclude_group] == j,"y.position"]<-seq(t[table_stat[,x] == dia & table_stat[,exclude_group] == j,"y.position"][[1,1]], |
|
|
t[table_stat[,x] == dia & table_stat[,exclude_group] == j,"y.position"][[1,1]]+diff(range(table[,value.var], na.rm = T))*bracket.inspace*(nrow(table_stat[table_stat[,x] == dia & table_stat[,exclude_group] == j,])-1), |
|
|
t[table_stat[,x] == dia & table_stat[,exclude_group] == j,"y.position"][[1,1]]+diff(range(table[,value.var], na.rm = T))*bracket.inspace*(nrow(table_stat[table_stat[,x] == dia & table_stat[,exclude_group] == j,])-1), |
|
|
by=diff(range(table[,value.var], na.rm = T))*bracket.inspace) |
|
|
by=diff(range(table[,value.var], na.rm = T))*bracket.inspace) |
|
|