ggplot2 - Creating grouped bar-plot of multi-column data in R -


i have following data

       input rtime rcost rsolutions  btime bcost  1   12 proc.     1    36     614425     40    36  2   15 proc.     1    51     534037     50    51  3    18-proc     5    62    1843820     66    66  4    20-proc     4    68    1645581 104400    73  5 20-proc(l)     4    64    1658509  14400    65  6    21-proc    10    78    3923623 453600    82  

i want create grouped bar chart data such x-axis contains input field (as groups) , y axis represent log scale rtime , btime fields (the 2 bars).

all solutions/examples checked online had similar data put 3 column layout. not know how use data have generate grouped bar-chart. or if there way convert data (manually converting not options because huge file lot of rows) r , ggplot compatible data format.

edit :

graph generated using gncs solution

enter image description here

as requested, ggplot2 solution:

df <- read.table(text = "       input rtime rcost rsolutions  btime bcost  1   12-proc.     1    36     614425     40    36  2   15-proc.     1    51     534037     50    51  3    18-proc     5    62    1843820     66    66  4    20-proc     4    68    1645581 104400    73  5 20-proc(l)     4    64    1658509  14400    65  6    21-proc    10    78    3923623 453600    82",header = true,sep = "")  dfm <- melt(df[,c('input','rtime','btime')],id.vars = 1)  ggplot(dfm,aes(x = input,y = value)) +      geom_bar(aes(fill = variable),stat = "identity",position = "dodge") +      scale_y_log10() 

enter image description here

note style difference here, since log(1) = 0, ggplot2 treats bar of 0 height , doesn't plot anything, whereas barplot plots little stub (which in opinion little misleading).


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -