I want a function to return 2 charts side by side:
GraficosKMeans <- function(dados){ 
  g1 <- ggplot(dados, aes(x = cluster, y = ValorMedio))+
    geom_col()
  g2 <- ggplot(dados, aes(x = cluster, y = FrequenciaMedia))+
    geom_col()
  
  par(mfrow=c(1,2))
  # also tried layout(matrix(c(1,2), 1, 2))
  return(list(g1, g2))
 # also tried g1
 # also tried g2
}
Calling this function with:
GraficosKMeans(dados)
Is returing the charts separately. Why is the plotting area not set into a 1*2 array?

