Browse Source

Correct for more than 1 facet.

main
Marcel Costa 1 week ago
parent
commit
217bca2480
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      R/ggstats_add_xy.R

+ 6
- 6
R/ggstats_add_xy.R

@ -70,12 +70,12 @@ ggstats_add_xy<-function(table_stat, table, xcol=NULL, group, y="max", bracket.o
}
}
}else{
for (dia in unique(pull(table_stat,all_of(exclude_group)))){
t[table_stat[,exclude_group] == dia, "y.position"]<-seq(t[table_stat[,exclude_group] == dia,"y.position"][[1,1]],
t[table_stat[,exclude_group] == dia,"y.position"][[1,1]]+
diff(range(table[,value.var], na.rm = T))*
bracket.inspace*(nrow(table_stat[table_stat[,exclude_group] == dia,])-1),
by=diff(range(table[,value.var], na.rm = T))*bracket.inspace)
for (dia in unique(pull(mutate(table_stat,dia=paste0(!!!syms(exclude_group))),dia))){
t[apply(table_stat[,exclude_group], 1, paste, collapse="") == dia, "y.position"]<-seq(t[apply(table_stat[,exclude_group], 1, paste, collapse="") == dia,"y.position"][[1,1]],
t[apply(table_stat[,exclude_group], 1, paste, collapse="") == dia,"y.position"][[1,1]]+
diff(range(table[,value.var], na.rm = T))*
bracket.inspace*(nrow(table_stat[apply(table_stat[,exclude_group], 1, paste, collapse="") == dia,])-1),
by=diff(range(table[,value.var], na.rm = T))*bracket.inspace)
}
}
return(cbind(table_stat,t) %>% as_tibble)

Loading…
Cancel
Save