[R] intervals on plot

Martin Maechler maechler at stat.math.ethz.ch
Thu Oct 14 10:41:45 CEST 1999


>>>>> "Nikita" == Nikita Atkins <nda at mailcall.com.au> writes:

    Nikita> Dear all R users I have been trying to plot a group of
    Nikita> intervals by using the bottom code:

    Nikita> col3 is just a column of 1500 floating point data.
(added a definition for 'col3' (and dropped ">")
  --> completely executable code, please use this in reports like this! -- MM)

    col3 <- 750+ 100* rt(1500, df = 3)

    breaks <- factor(cut(col3,breaks=360+5*(0:155)))
    par(tck=0,lty="solid")
    plot(breaks,ann=FALSE,axes=FALSE)

    Nikita> Unfortunately when i do the plot, the x-axis has some of the
    Nikita> intervals as labels dispite me having both 'ann' and 'axes'
    Nikita> both as FALSE.

The reason is an imperfect implementation of  plot.factor(),
or barplot.default(), respectively,
which are called by the above  plot() command.

I'll have a look at fixing this. 

Note however that you are really just (trying) to plot a histogram of col3
and I wonder why you are *not* just using
    hist(col3)
or
    hist(col3, breaks =360+5*(0:155)), ...)

    Nikita> Could anyone tell me how to remove these from my plot or how to
    Nikita> bypass this altogether, maybe by changing the names of the
    Nikita> intervals to something else.

A workaround:

  tb <- table(breaks); dimnames(tb) <- NULL
  barplot(tb, axes=FALSE)


Apropos, we use locally the function

  unname <- function (obj) 
  {
      if (length(names(obj))) 
	  names(obj) <- NULL
      if (length(dimnames(obj)) && !is.data.frame(obj)) 
	  dimnames(obj) <- NULL
      obj
  }

with which you could abbreviate the above to

     barplot(unname(table(breaks)), axes= FALSE)

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list