r - Single error bar on stacked bar plot ggplot -


I'm trying every success without having to make a stacked bar plot with an error bar at any one time For each section within the Yes Bar, I can attract all error bars for each section, but there is no solution to attract a single error bar.

Here the data frame is df

  SP type or rate se 1h below the district 14.5454545 8.0403025 2h district top 2.7272727 1.9 403407 3h district WP 0.9 9 9.99.99 5.4545455 1.4845392 5h that top 15.4545455 5.0797135 6H WP 0.0000000 0.0000000 7h Heads down 9.090 9 091 3.8330638 8H Heads Top 8.1818182 4.1659779 9H Heads WP 3.6363636 2.0100756 10 N Dist Bottom 19.0909091 8.932 9 715 11 N Dish Top 0.0000000 0.0000000 12 NDP 0.0000000 0.0000000 13 N He Down 22.7272727 7.07,43,137 14 N He Top 0.0000000 0.0000000 15 N He WP 3.63,63,636 2.77,73,186 16 Ann HeDis 14.5454545 5.28,35,13 9 17 N HeDis Top 10.0000000 4.38,08,583 18 Ann HeDis WP 0.0000000 0.0000000   

Here is the script (every error bar's position is not correct, but it does not matter because it is not the same as the script to drag the plot with the strike bar for each section within the barcode I want to):

  dodge & lt; - position_buscle (width = 0.65) column & lt; - c (top = "dark", bottom = "light", well_play = "white") Stacked_plot_bis & lt; -ggplot (df, aes (x = factor (type), y = rate, filling = factor (or))) + geom_bar (AES (width = .65), state = "detection", color = "black") + Geom_errorbar + (facet_grid (~ SP)   

This pulls the error bars of all sections within each bar, how do I take a single overall error bar at the top of each individual bar, which takes into account the sections, but only copy The overall price for each type?

Any help would be greatly appreciated!

You can create a dummy data set (I call it data.table Package) which will calculate mean (to) (although I do not think this is the best practice) and plot it as following (I have changed the color of error bars so that You can see them better)

  dodge & lt; - position_dodge (width = 0.65) cols & lt; - c (top = "darkgrey", below = "lightgrey", well_plate = "white") library (data.table) dummy & lt; - data.table (DF) [, list (rate = sum (amount), from = mean (c), or = "wp"), = c ("sp", "type")] ggplot (df, aes X = factor (type), y = rate, fill = factor (or)) = geom_bar (AES (width = .65), state = "detection", color = "black") + geom_errorbar (data = dum y, aes (Ymax = rate +, ymin = rate -se), position = "dodge", color = "red", width = .65) + scale_fill_manual (value = column) + facet_grid (. ~ SP)  < / Pre> 

Enter image details here

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -