0

I'm trying to put together a ggpairs visualization that uses the first column from a dataframe to specify the point colors, and columns 4-7 of the dataframe to create the point distributions:

require(GGally)
require(ggplot2)

df <- read.table('https://gist.githubusercontent.com/duhaime/46dde948263136d0b52be1575232a83e/raw/80f14650e4f4b9ef38a5dec3f5bbb8c62954ee59/match-stats.tsv',
            sep='\t',
            colClasses=c(
              rep('character', 3),
              rep('numeric', 4)
            )
          )

ggpairs(df, aes(colour = V1, alpha = 0.4),
        columns= 4:7 )

However, this throws:

Error in colnames<-(*tmp*, value = c("V1", "ggally_cor")) :
'names' attribute [2] must be the same length as the vector [1]

Does anyone know how to resolve this and achieve the plot described above? Any help would be greatly appreciated!

duhaime
  • 25,611
  • 17
  • 169
  • 224
  • 2
    has something to do with the `V*` names, looks like anything else will work `names(df) <- letters[1:7]; ggpairs(df, aes(colour = a, alpha = 0.4), columns = 4:7)` – rawr Apr 01 '18 at 03:18
  • 1
    I confirm @rawr's observation. That is strange. Maybe a tiny bug in the `GGally` package. – hpesoj626 Apr 01 '18 at 03:47
  • @rawr thanks very much! If you post your comment as an answer I'll accept it! – duhaime Apr 01 '18 at 11:10

1 Answers1

0

Just to close this loop, using @rarw's suggestion to provide names to df resolved this problem:

names(df) <- letters[1:7];
ggpairs(df, aes(colour = a, alpha = 0.4), columns = 4:7)
duhaime
  • 25,611
  • 17
  • 169
  • 224