Note that there are some explanatory texts on larger screens.

plurals
  1. POggplot and errorbars
    text
    copied!<p>I'm trying to create a plot with errorbars from the following data (dput of the dataframe in the end). I'd like to create errorbars for the "est A" and "est B" variables for each "loc", but I cannot figure out the right way to melt/cast the data so that each "loc" would have two rows with several columns.</p> <p>I.e. I'd like to convert the dataframe into</p> <p>loc est value lb ub</p> <p>a A 0.56 0.26 1.20</p> <p>a B 0.26 0.11 0.60</p> <p>b A 0.13 </p> <p>b B 0.03</p> <p>c A</p> <p>c B</p> <pre><code>ggplot(test,aes(x=Loc,y=value,color=est))+geom_point()+geom_errorbar(aes(ymax=ub,ymin=lb)) &gt; dput(test) structure(list(Loc = c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s"), `est A` = c(0.563270934055709, 0.137109873453407, 0.0946514679398302, 0.185103062070327, 0.0322566231880829, 0.122509922923046, 0.120243043198876, 0.496530499385046, 0.469200921538171, 0.0605252215342125, 0.102364314964088, 0.115500654388976, 0.226320301860998, 0.553299923910439, 0.0284461712437990, 0.161231809656951, 0.129270683014873, 0.0691902563736868, 4.22775563209408e-10), `est B` = c(0.261222076585074, 0.0361169058045732, 0.0389295009573361, 0.0341489915400374, 0.00722206105211422, 0.0756192543690879, 0.0638910584951127, 0.112923798991901, 0.169215410079679, 0.0235142527703486, 0.0347964005083873, 0.0485649792804626, 0.057534910753763, 0.142573116854277, 0.0221769276223588, 0.104198059736499, 0.0234801538140553, 0.072563099770018, 1.93211916678252e-10), `A lb` = c(0.262976608413878, 0.0724138165552355, 0.0496821188642757, 0.083935851825787, 0.00630380846921399, 0.0490562081838664, 0.0467393615329014, 0.20284436584412, 0.178474018619480, 0.0171506568665928, 0.0503363150211533, 0.0600281091658352, 0.0747597162489745, 0.276929613768523, 0.00665167561787145, 0.0580348444006193, 0.0516432163190537, 0.0228220757228112, 0), `A ub` = c(1.20647287629726, 0.259606775235633, 0.180324442434493, 0.408206300913301, 0.165057321233572, 0.305948661143090, 0.309340756132258, 1.21542708762748, 1.23351010121895, 0.213595459944227, 0.208168853315217, 0.222235904972905, 0.685140094216929, 1.10548237017075, 0.121651250740107, 0.447932560408103, 0.323583825296458, 0.209765826526966, Inf), `B lb` = c(0.111866193520147, 0.0169169666997800, 0.0186761266424921, 0.0121471488870159, 0.00126380823047679, 0.0279532804037691, 0.0225442254744942, 0.0369377660459994, 0.0509571176650792, 0.00592607390737984, 0.0157043256006381, 0.0231925392578512, 0.0153998561264800, 0.0612241780775462, 0.00507024995333768, 0.0364091610491575, 0.00745586930827693, 0.0243798413908829, 0), `B ub` = c(0.609987442570209, 0.0771078472899858, 0.0811466999446844, 0.0960022499146318, 0.0412706331409062, 0.204565315724654, 0.181069310198491, 0.345223486522794, 0.561920617187038, 0.0933029341161755, 0.0770991075408484, 0.101694652159027, 0.214954342966326, 0.332010886676128, 0.0970003694676995, 0.298200654450461, 0.0739441103828987, 0.215973654783605, Inf)), .Names = c("Loc", "est A", "est B", "A lb", "A ub", "B lb", "B ub"), row.names = c(NA, -19L), class = "data.frame") </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload