.data pronoun only allows one facet variable. I have changed into !!!syms().
This commit is contained in:
+3
-3
@@ -10,11 +10,11 @@ ggstats_add_xy<-function(table_stat, table, xcol=NULL, group, y="max", bracket.o
|
||||
if (is.null(exclude_group)){
|
||||
table_agg<-table %>% group_by(.data[[x]])
|
||||
}else{
|
||||
table_agg<-table %>% group_by(.data[[x]], .data[[exclude_group]])
|
||||
table_agg<-table %>% group_by(.data[[x]], !!!syms(exclude_group))
|
||||
}
|
||||
if (y == "max"){
|
||||
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"){
|
||||
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))
|
||||
@@ -55,7 +55,7 @@ ggstats_add_xy<-function(table_stat, table, xcol=NULL, group, y="max", bracket.o
|
||||
if (!is.null(exclude_group)){
|
||||
for (j in unique(pull(table_stat, all_of(exclude_group)))){
|
||||
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"][[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)
|
||||
|
||||
Reference in New Issue
Block a user