Tuesday, 15 July 2014

r - ggplot2: fill & position='dodge' for geom_line -



r - ggplot2: fill & position='dodge' for geom_line -

how utilize 2 variables create x-axis? want show value on y-axis possible combinations of 2 predictors.

for geom_bar, need utilize fill , position='dodge' aesthetics. not seem work geom_line. manually create interaction term , restructure info frame there must way quicker.

this seems rather simple question can't seem find reply anywhere!

thank you.

edit: sorry, more information--i want graph looks this:

this representation of i'd graph like. i've made info , plotted in excel. can see how x-axis beingness shared 2 variables, 1 nested within other. both variables numeric, 2 levels each.

i'd prefer avoid manually creating interaction term because seems more rough way of doing it. ggplot flexible , i'm guessing have in mind possible.

until post details data, general reply is:

1) x-axis, said:

interaction(as.factor(df$var1), as.factor(df$var2), drop = true)

i don't see what's undesirable that, it's one-liner, can inline ggplot() call. what's problem? might want manipulate order of each individual factor(levels = ...), or reorder output interaction?

2) seem asking plot type, or geom. without details. "fill & position='dodge' geom_line", there isn't any... want achieve? post image of similar graph. geom_area or geom_ribbon? line-graph discontinuous gaps between series? or what?

r ggplot2

No comments:

Post a Comment