[R] Plot qualitative y axis
John Kane
jrkr|de@u @end|ng |rom y@hoo@c@
Mon May 21 17:19:54 CEST 2018
What I think is the ggplot2 version of what you want. Note that I am using the reshape2 package which is a bit old fashioned.
=============================================================library(reshape2)
library(ggplot2)
dat1 <- structure(list(N = c("I", "II", "III", "IV", "V", "VI", "VII",
"VIII", "IX", "X", "XI", "XII", "XIII", "XIV"), M = c(10L, 124L,
321L, 777L, 896L, 1706L, 635L, 1437L, 693L, 1343L, 1221L, 25L,
3L, 7L), W = c(106L, 484L, 874L, 1140L, 996L, 1250L, 433L, 654L,
333L, 624L, 611L, 15L, NA, 8L)), .Names = c("N", "M", "W"), class = "data.frame", row.names = c(NA,
-14L))
dat2 <- melt(dat1)
=============================================================
On Monday, May 21, 2018, 10:47:54 a.m. EDT, Bert Gunter <bgunter.4567 using gmail.com> wrote:
See ?barplot and set the horiz argument to TRUE.
(This is in the base R plotting version. The ggplot2 and lattice systems
have other ways of doing this)
Note: if you search on e.g. "barplots in R" or similar, you should find
numerous examples with code.
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, May 21, 2018 at 5:44 AM, Pedro páramo <percentil101 using gmail.com>
wrote:
> Hi all,
>
> I´m trying to plot this data
>
> N M W
> I 10 106
> II 124 484
> III 321 874
> IV 777 1140
> V 896 996
> VI 1706 1250
> VII 635 433
> VIII 1437 654
> IX 693 333
> X 1343 624
> XI 1221 611
> XII 25 15
> XIII 3
> XIV 7 8
> So that in de Y axis will be the level (qualitative data) and in the X axis
> will be M and W variables. So x axis will be wwith a lenght between 0 and
> 2000.
>
> I would like to plot a line with M and other with W so it will be obvious
> that above V (in the Y axis) thera are more W and below level V there are
> more M.
>
> Can you please guide me?
>
> In excel putting Y as X axis is easy but dind´nt achieve to invert rows and
> I ´m trying to plot it in R.
>
> Many thanks in advance
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help
mailing list