Reppo for internal functions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
557 B

gglegend<-function(data, x, y, var, stat="median", color="black", ...){
if (stat == "median"){
data<-data %>% group_by({{var}}) %>% summarise("{{x}}":=median({{x}}, na.rm=T), "{{y}}":=median({{y}}, na.rm=T))
}
if (stat == "mean"){
data<-data %>% group_by({{var}}) %>% summarise("{{x}}":=mean({{x}}, na.rm=T), "{{y}}":=mean({{y}}, na.rm=T))
}
if (!is.null(color)){
return(geom_label(data = data, aes({{x}},{{y}}, label={{var}}), color=color, ...))
}else{
return(geom_label(data = data, aes({{x}},{{y}}, label={{var}}),...))
}
}