-2

I have this dataset

  Feature   Distance    LOF Mahalanobis Cook    DIFFTS  OCSVM   DBSCAN  PCA Gaussian
V1V2    A   8.5 8.8 9.5 10.5    3.8 7.3 0.0 5.4
 V1V2   B   3.7 5.4 5.2 5.3 3.5 4.8 0.0 1.7
 V1V2   C   8.8 9.3 7.7 8.4 4.6 6.8 0.0 3.1
 V1V3   A   6.2 14.8    11.9    11.2    4.1 8.0 0.0 4.3
 V1V3   B   4.7 6.5 5.4 5.6 3.4 5.6 0.0 3.7
V1V3    C   8.5 19.5    14.3    8.4 4.6 8.8 0.0 3.1
     ....       

V1V2V3V4V5  A   2.0 12.0    9.4 10.5    4.0 4.5 0.0 1.0
V1V2V3V4V5  B   4.3 4.7 4.5 5.1 3.7 3.8 0.0 5.6
V1V2V3V4V5  C   3.5 7.8 9.2 9.7 4.5 4.7 0.0 12.9

I would like to generate a visualize a graph with multiple barplots.

            LOF           ----                     Gaussian

     V1V2   Barplot (A,B,C) ....................... Barplot (A,B,C)  

Feature

      ............................................................           

     V1V2V3V4V5 Barplot (A,B,C)  ..................  Barplot (A,B,C)      

It's a graph composed by 8x26 barplots.

Raúl

  • 3
    Please read the info about how to give a [minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). – Jaap Oct 05 '15 at 07:21

1 Answers1

0

You could use ggplot2 and facet_grid. I've used a subset of the data presented, but it can scale (although 26*8 barplots is a lot).

library(reshape2)
library(ggplot2)

First, reshape the data, as ggplot works a lot better with data in long format.

m_df <- melt(df, id.vars=c("Feature","Distance"))

Then plot:

p1 <- ggplot(m_df, aes(x=Distance,y=value)) +
  geom_bar(stat="identity") +
  facet_grid(Feature~variable)

enter image description here Data used:

 df <- read.table(text=" Feature   Distance    LOF Mahalanobis Cook    DIFFTS  OCSVM   DBSCAN  PCA Gaussian
    V1V2    A   8.5 8.8 9.5 10.5    3.8 7.3 0.0 5.4
     V1V2   B   3.7 5.4 5.2 5.3 3.5 4.8 0.0 1.7
     V1V2   C   8.8 9.3 7.7 8.4 4.6 6.8 0.0 3.1
     V1V3   A   6.2 14.8    11.9    11.2    4.1 8.0 0.0 4.3
     V1V3   B   4.7 6.5 5.4 5.6 3.4 5.6 0.0 3.7
    V1V3    C   8.5 19.5    14.3    8.4 4.6 8.8 0.0 3.1",header=T

)
Heroka
  • 12,889
  • 1
  • 28
  • 38