[R] Why horizontal bars instead of a line

Greg Snow Greg.Snow at imail.org
Wed Sep 24 20:05:43 CEST 2008

Remember that computers are not as smart as you.  Some smart people have written instructions for the computer on what to do in certain cases, but they can't anticipate everything, so when you tell the computer to do something that was different from what is anticipated, it either gives an error or the results of a wrong guess.

In your case, since GrSe has a G in the front and your data is probably in a data frame, the plot function sees a factor (generally what gets created automatically when characters are seen) and passes the data to plot.factor which plots boxplots (and with 1 point per year, the 5 number summary for the boxplot gives all the same value, hence the horizontal line).

What you probably want to do is to plot your clone data against a numerical representation of the year (without the G), but suppress the axis labels and add the labels yourself (with the G), see ?axis for detail on doing this.

Hope this helps,

Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Schreiber, Stefan
> Sent: Wednesday, September 24, 2008 9:28 AM
> To: r-help at r-project.org
> Subject: [R] Why horizontal bars instead of a line
> Hey list!
> It looks simple, though it's not possible for me to plot the following
> properly:
> (some made-up data)
> GrSe    Clone1  Clone2  Clone3  Clone4  Clone...
> G1999   2       3       6       5
> G2000   2       5       7       4
> G2001   5       3       7       3
> G2002   4       5       8       3
> G...
> GrSe=Growing Season.
> I've read the file as "x" and then tried:        plot(x$GrSe,x$Clone1)
> The output is 4 horizontal bars. Even if I write
> plot(x$GrSe,x$Clone1,type="n") R is still plotting!
> I figured already that if I delete the "G" in front of the years it'll
> work, however, I'd like to keep the "G".
> Is that possible?
> Hope it is an appropriate question for the list.
> Thanks,
> Stefan
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> 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.

More information about the R-help mailing list