
Last chance! 50% off unlimited learning
Sale ends in
Calculate a frequency distribution for two continuous variables.
Freq2D(x, ...)# S3 method for formula
Freq2D(formula, data, subset, ...)
# S3 method for default
Freq2D(x, y, n=20, pad=0, dnn=NULL, ...)
The layout
argument specifies one of the following formats for
the binned frequency output:
matrix
that is easy to read, aligned like a
scatterplot.
list
with three elements (x, y, matrix) that can be
passed to various plotting functions.
data.frame
with three columns (x, y, frequency) that
can be analyzed further.
a vector of x values, or a data frame whose first two columns contain the x and y values.
a vector of y values.
a formula
, such as y~x
.
a data.frame
, matrix
, or list
from
which the variables in formula
should be taken.
an optional vector specifying a subset of observations to be used.
the desired number of bins for the output, a scalar or a vector of length 2.
number of rows and columns to add to each margin, containing only zeros.
the names to be given to the dimensions in the result.
named arguments to be passed to the default method.
Arni Magnusson <arnima@hafro.is>
The exact number of bins is determined by the
pretty
function, based on the value of n
.
Padding the margins with zeros can be helpful for subsequent analysis, such as smoothing.
The print
logical flag only has an effect when layout=1
.
cut
, table
, and print.table
are the basic underlying functions.
Freq
, PercTable
Freq2D(quakes$long, quakes$lat, dnn="")
Freq2D(lat ~ long, quakes, n=c(10, 20), pad=1)
# range(Freq2D(saithe, print=FALSE))
# Layout, plot
# Freq2D(saithe, layout=2)
# Freq2D(saithe, layout=3)
# contour(Freq2D(saithe, layout=2))
# lattice::contourplot(Freq ~ Bio + HR, Freq2D(saithe,layout=3))
Run the code above in your browser using DataLab