Añadiendo la opción de excluir del agrupamiento.
This commit is contained in:
+3
-4
@@ -5,10 +5,10 @@ ggheatmap<-function(df, x=NULL, y=NULL, value=NULL, grouping="mean", exclude_gro
|
||||
|
||||
df<-rename(df, "VarX"=all_of(x), "VarY"=all_of(y), "Value"=all_of(value))
|
||||
|
||||
if (!is.null(exclude_group)){
|
||||
if (is.null(exclude_group)){
|
||||
df<-df %>% group_by(VarX,VarY)
|
||||
}else{
|
||||
df<-df %>% group_by(VarX,VarY,all_of(exclude_group))
|
||||
df<-df %>% group_by_("VarX","VarY",exclude_group) #%>% rename(exclude_group="all_of(exclude_group)")
|
||||
}
|
||||
if (grouping == "mean"){
|
||||
df<-df %>% summarise(Value=mean(Value)) %>% ungroup
|
||||
@@ -16,8 +16,7 @@ ggheatmap<-function(df, x=NULL, y=NULL, value=NULL, grouping="mean", exclude_gro
|
||||
if (grouping == "median"){
|
||||
df<-df %>% summarise(Value=median(Value)) %>% ungroup
|
||||
}
|
||||
|
||||
order<-clustsort(df %>% spread(VarY,Value) %>% as.data.frame)
|
||||
order<-clustsort(df %>% spread(VarY,Value) %>% select(!all_of(exclude_group)) %>% as.data.frame)
|
||||
|
||||
df$VarX<-factor(df$VarX, levels=order$x)
|
||||
df$VarY<-factor(df$VarY, levels=order$y)
|
||||
|
||||
Reference in New Issue
Block a user