0

I am trying to don't loose the order of dataframe, the information has order in the dataframe. But since the data is duplicated into the dataframe, I am obtaining error message or introducing NA. I didnt find a solution similar for this, I tried with this How to preserve the order of tiles in geom_tile ggplot, but it didn't work

library(readr)
library(ggplot2)
library(RColorBrewer)

url_soccer <- 'https://raw.githubusercontent.com/frm1789/soccer_ea/master/tableau.m.csv'

tableau.m <- read_csv(url_soccer)

tableau.m <- tableau.m[,-1]

(p <- ggplot(tableau.m, aes(Team, variable)) + 
geom_tile(aes(fill = rescale), colour = "white") + 
scale_fill_gradient(low = "white", high = "steelblue"))

The expected solution is this: How the visualization should be...

A89
  • 89
  • 9
  • In the others cases (at least as far as I looked for) they didn't find repetitive elements in the columns. – A89 Nov 26 '18 at 15:25

1 Answers1

1

Reorder your variables, see:

tableau.m$Team <- factor(tableau.m$Team, c("Brasil", "Argentina", "Uruguay"))
tableau.m$variable <- factor(tableau.m$variable, c("Titles", "Match", "Points", "Points_1", "Performance"))

ggplot(tableau.m, aes(variable, Team, fill = rescale)) + 
  geom_tile(show.legend = FALSE) + 
  scale_fill_gradient(low = "white", high = "steelblue") +
  theme_minimal()

enter image description here

zx8754
  • 52,746
  • 12
  • 114
  • 209