nos.hist: nos.hist text-based plot of a histogram.

Description Usage Arguments Note Author(s) See Also Examples

View source: R/NostalgiR.R

Description

Plots a text-based of a histogram, with the option to plot densities or frequencies.

Usage

1
2
3
nos.hist(data, breaks = "Sturges", freq = T, xlab = NULL, ratio = 0.25,
  width = round(options()$width * 0.8), height = round(ratio * width),
  pch = "o")

Arguments

data

A numeric vector containing the values to be plotted. NA and NaN are allowed, but are removed for the plot. Infinities will cause an error.

breaks

Either a numerical value or a character string to specify the number of breaks to used. The default setting is 'Sturges', which is the default option in hist; see hist for other options.

freq

If TRUE, the y-coordinate will display frequencies. If FALSE, then the y-coordinate will display densities.

xlab

Label of the x-axis of the plot.

ratio

Coefficient that controls the aspect ratio of the plot.

width

Width of the plot in points.

height

Height of the plot in points.

pch

A single-character plot symbol.

Note

Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position. Histogram columns are plotted at the midpoint of each bin.

Author(s)

Hien D. Nguyen

See Also

hist, and txtplot.

Examples

1
2
3
4
5
6
7
8
9
## Plot a histogram for the frequencies of 100 random standard normal points
## using 'Sturges' breaks and plot symbol 'o'.
data <- rnorm(100)
nos.hist(data)

## Plot a histogram for the densities of 1000 random chi-squared(3) points
## using 'FD' breaks and plot symbol '#'.
data <- rchisq(1000,3)
nos.hist(data,breaks='FD',freq=FALSE,pch='#')

Example output

Loading required package: txtplot
     +----------+-----------+-----------+----------+-----------+
  20 +                   o                                     +
     |             o     o                                     |
F    |             o     o                                     |
r 15 +             o     o     o     o                         +
e    |             o     o     o     o                         |
q    |             o     o     o     o                         |
u 10 +             o     o     o     o                         +
e    |             o     o     o     o                         |
n    |       o     o     o     o     o     o     o             |
c  5 +  o    o     o     o     o     o     o     o             +
y    |  o    o     o     o     o     o     o     o             |
     |  o    o     o     o     o     o     o     o    o        |
   0 +  o    o     o     o     o     o     o     o    o     o  +
     +----------+-----------+-----------+----------+-----------+
               -1           0           1          2            
       +-+-------------+------------+-------------+------------+
  0.25 +    #                                                  +
       |    # #                                                |
   0.2 +    # #                                                +
D      |   ## ##                                               |
e      |   ## ###                                              |
n 0.15 +  ### ### #                                            +
s      |  ### ### ##                                           |
i  0.1 +  ### ### ## #                                         +
t      |  ### ### ## ##                                        |
y      |  ### ### ## ### #                                     |
  0.05 +  ### ### ## ### ###                                   +
       |  ### ### ## ### ### ## ##                             |
     0 +  ### ### ## ### ### ## ### ### ### ## ### ### ## ###  +
       +-+-------------+------------+-------------+------------+
         0             5           10            15             

NostalgiR documentation built on May 2, 2019, 2:45 p.m.