问题描述:

I have a big database with data of companies, and I would like to build a tool to quickly see disturbant evolution, in order to explain or correct them. Companies are organised in a complexed imbricated nomenclature : agriculture is divised in growing and raising, raising is divised in horse, cow... and so on. What I imagine is a bar diagram showing one bar per year, for every big sector, and to be able to click on a bar, and get the bar diagram for the level of nomenclature just behind. And to be able to do this on the 5 levels of nomenclature.

I am not sure I'm quite clear, so here is a quick example :

require(ggplot2)

#here is my data...

activity <- rep(c("growing of rice","growing of grapes","manufacture of ice cream","manufacture of cheese"),2)

section <- rep(c("agriculture","agriculture","manufacture","manufacture"),2)

annee <- c(rep("2012",4),rep("2013",4))

total <- c(50,65,98,62,200,65,105,70)

data <- data.frame(activity,section,total,annee)

#I want first to get this graph...

ggplot(data=data,aes(x=section,y=total,fill=annee))+geom_bar(stat="identity",position="dodge")

#And then, when I click on "agriculture" somewhere, get this one...

ggplot(data=data[section=="agriculture",],aes(x=activity,y=total,fill=annee))+geom_bar(stat="identity",position="dodge")

Is there an not-to-complex way to do this ? Has anybody ever tried this ?

相关阅读:
Top