inthist | R Documentation |
inthist it is common to want to generate a list of counts as integers from an input vector and then plot then as columns of those counts. Alternatively, it is common to have a two-column matrix of values and counts or totals where one wants to plot columns of those counts or totals against those values. inhist allows one to enter either a vector of integers to be counted and plotted OR a matrix of values in column 1 and counts or totals in column 2. The option of rounding non-integers is available.
inthist(
x,
col = 1,
border = NULL,
width = 0.9,
xlabel = "",
ylabel = "",
main = "",
lwd = 1,
xmin = NA,
xmax = NA,
ymax = NA,
plotout = TRUE,
prop = FALSE,
inc = 1,
xaxis = TRUE,
roundoff = TRUE,
...
)
x |
a vector of integers to be counted and plotted OR a matrix of values in column 1 and counts or totals in column 2 |
col |
the colour of the fill; defaults to black = 1, set this to 0 for an empty bar, but then give a value for border |
border |
the colour of the outline of each bar defaults to col |
width |
denotes the width of each bar; defaults to 0.9, should be >0 and <= 1 |
xlabel |
the label for the x axis; defaults to "" |
ylabel |
the label for the y axis; defaults to "" |
main |
the title for the individual plot; defaults to "" |
lwd |
the line width of the border; defaults to 1 |
xmin |
sets the lower bound for x-axis; used to match plots, defaults to NA whereupon the minimum of values is used |
xmax |
sets the upper bound for x axis; used with multiple plots, defaults to NA whereupon the maximum of values is used |
ymax |
enables external control of the maximum y value; mainly of use when plotting multiple plots together. |
plotout |
plot the histogram or not? Defaults to TRUE |
prop |
plot the proportions rather than the counts, default=FALSE |
inc |
sets the xaxis increment; used to customize the axis; defaults to 1. |
xaxis |
set to FALSE to define the xaxis outside of inthist; defaults to TRUE |
roundoff |
if values are not integers should they be rounded off to become integers? default=TRUE. Obviously only useful when inputting a matrix. |
... |
available to pass extra plot arguments, such as panel.first=grid(), or whatever to the internal plot call |
a matrix of values and counts with the proportions of counts and values is returned invisibly
x <- trunc(runif(1000)*10) + 1
inthist(x,col="grey",border=3,width=0.75,xlabel="Random Uniform",
ylabel="Frequency")
x <- as.matrix(cbind(c(1,2,3,4,5,6,7,8),trunc(runif(8,1,20))))
inthist(x,col="grey",border=3,width=0.75,xlabel="integers",
ylabel="Frequency")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.