wtd.hist(weights)
wtd.hist()所属R语言包:weights
Weighted Histograms
加权直方图
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Produces weighted histograms by adding a "weight" option to the his.default function from the graphics package (Copyright R-core). The code here was copied from that function and modified slightly to allow for weighted histograms as well as unweighted histograms. The generic function hist computes a histogram of the given data values. If plot=TRUE, the resulting object of class "histogram" is plotted by plot.histogram, before it is returned.
加权直方图,通过添加一个“权重”选项的his.default功能从图形包(版权R-核心)。从该函数的代码被复制,并稍加修改,以允许加权直方图,以及未加权的直方图。通用功能历史计算给定的数据值的直方图。如果图= TRUE,生成的对象的类“直方图”绘制plot.histogram,然后才返回。
用法----------Usage----------
wtd.hist(x, breaks = "Sturges",
freq = NULL, probability = !freq,
include.lowest = TRUE, right = TRUE,
density = NULL, angle = 45, col = NULL, border = NULL,
main = paste("Histogram of" , xname),
xlim = range(breaks), ylim = NULL,
xlab = xname, ylab,
axes = TRUE, plot = TRUE, labels = FALSE,
nclass = NULL, weight = NULL, ...)
参数----------Arguments----------
参数:x
a vector of values for which the histogram is desired.
该直方图所需的值的矢量。
参数:breaks
one of:
之一:
a vector giving the breakpoints between histogram cells,
一个向量给直方图单元之间的断点,
a single number giving the number of cells for the histogram,
一个单一的数字给予的单元数的直方图,
a character string naming an algorithm to compute the number of cells (see "Details"),
一个字符串,命名一种算法来计算单元的数量(见“详细信息”),
a function to compute the number of cells.
一个函数来计算单元的数目。
In the last three cases the number is a suggestion only.
在过去的三年宗数仅是一个建议。
参数:freq
logical; if TRUE, the histogram graphic is a representation of frequencies, the counts component of the result; if FALSE, probability densities, component density, are plotted (so that the histogram has a total area of one). Defaults to TRUE if and only if breaks are equidistant (and probability is not specified).
逻辑;若TRUE,直方图的图形是表示频率,counts组件的结果;若FALSE,概率密度,组分density,绘制(这样直方图的一个有一个总面积)。默认为TRUE当且仅当breaks是等距的(和probability未指定)。
参数:probability
an alias for !freq, for S compatibility.
!freq,S兼容性的别名。
参数:include.lowest
logical; if TRUE, an x[i] equal to the breaks value will be included in the first (or last, for right = FALSE) bar. This will be ignored (with a warning) unless breaks is a vector.
逻辑;如果TRUE,x[i]等于breaks值将包含在第一个(或最后,right = FALSE)条形。这将被忽略(警告),除非breaks是一个向量。
参数:right
logical; if TRUE, the histogram cells are right-closed (left open) intervals.
逻辑,如果TRUE,直方图单元是正确的闭(开)的时间间隔。
参数:density
the density of shading lines, in lines per inch. The default value of NULL means that no shading lines are drawn. Non-positive values of density also inhibit the drawing of shading lines.
阴影的线密度,在每英寸的线。 NULL的默认值是指没有阴影画线。 density非正面的价值观也抑制的阴影线图。
参数:angle
the slope of shading lines, given as an angle in degrees (counter-clockwise).
阴影线的斜率,作为度(逆时针方向)的角度给出。
参数:col
a colour to be used to fill the bars. The default of NULL yields unfilled bars.
要使用一种颜色,以填补条形。默认情况下,NULL产生悬空的条形。
参数:border
the color of the border around the bars. The default is to use the standard foreground color.
的条形周围的边框的颜色。默认情况下是使用标准的前景色。
参数:main, xlab, ylab
these arguments to title have useful defaults here.
这些参数来title在这里可以使用默认值。
参数:xlim, ylim
the range of x and y values with sensible defaults. Note that xlim is not used to define the histogram (breaks), but only for plotting (when plot = TRUE).
合理的默认值x和y值的范围。 xlim不用于定义的直方图(截断),但仅限于绘制(plot = TRUE“)。
参数:axes
logical. If TRUE (default), axes are draw if the plot is drawn.
逻辑。如果TRUE(默认),轴的画,如果该图的绘制。
参数:plot
logical. If TRUE (default), a histogram is plotted, otherwise a list of breaks and counts is returned. In the latter case, a warning is used if (typically graphical) arguments are specified that only apply to the plot = TRUE case.
逻辑。如果TRUE(默认值),绘制的直方图,否则,将返回一个列表,截断和计数。在后一种情况下,一个警告(通常是图形化的)指定参数,只适用于plot = TRUE情况下使用。
参数:labels
logical or character. Additionally draw labels on top of bars, if not FALSE; see plot.histogram in the graphics package.
逻辑或字符。此外绘制标签顶部的条形,如果不FALSE看plot.histogram中graphics包。
参数:nclass
numeric (integer). For S(-PLUS) compatibility only, nclass is equivalent to breaks for a scalar or character argument.
数字(整数)。 S(-PLUS)的兼容性,nclass是breaks一个标量或字符参数。
参数:weight
numeric. Defines a set of weights to produce a weighted histogram. Will default to 1 for each case if no other weight is defined.
数字。定义了一组的权重以产生一个加权的直方图。将默认为1,每一种情况下,如果没有其他重定义。
参数:...
further arguments and graphical parameters passed to plot.histogram and thence to title and axis (if plot=TRUE).
进一步的论据和图形参数传递给plot.histogram和从那里到title和axis(如果plot=TRUE)。
Details
详细信息----------Details----------
The definition of histogram differs by source (with country-specific biases). R's default with equi-spaced breaks (also the default) is to plot the (weighted) counts in the cells defined by breaks. Thus the height of a rectangle is proportional to the (weighted) number of points falling into the cell, as is the area provided the breaks are equally-spaced.
直方图的定义,不同的来源(特定国家的偏见)。 R的等间隔符(默认值),默认情况下,在单元中所定义的breaks绘制(加权)计数。因此,一个矩形的高度(加权)的数量的点落入单元是成比例的,因为所提供的区域的场所是相等的间隔。
The default with non-equi-spaced breaks is to give a plot of area one, in which the area of the rectangles is the fraction of the data points falling in the cells.
默认情况下,具有非等间隔的场所的区域1中,得到的曲线图,在其中的矩形的面积是在单元格中的数据点下降的馏分。
If right = TRUE (default), the histogram cells are intervals of the form (a, b], i.e., they include their right-hand endpoint, but not their left one, with the exception of the first cell when include.lowest is TRUE.
如果right = TRUE(默认),直方图单元间隔的形式(a, b],即,他们包括他们的右手终点,但不是他们的左,除第一个单元格的时候include.lowest是TRUE。
For right = FALSE, the intervals are of the form [a, b), and include.lowest means "include highest".
对于right = FALSE,间隔的形式[a, b)和include.lowest的意思是“包括最高”。
The default for breaks is "Sturges": see nclass.Sturges. Other names for which algorithms are supplied are "Scott" and "FD" / "Freedman-Diaconis" (with corresponding functions nclass.scott and nclass.FD). Case is ignored and partial matching is used. Alternatively, a function can be supplied which will compute the intended number of breaks as a function of x.
的默认值breaks是"Sturges":看nclass.Sturges。算法提供的其他名称是"Scott"和"FD"/"Freedman-Diaconis"(与相应的功能nclass.scott和nclass.FD)。不区分大小写,并使用部分匹配。或者,可以提供一个函数,这将计算预期的断裂数的函数的x。
值----------Value----------
an object of class "histogram" which is a list with components:
类的一个对象"histogram"这是一个组件列表:
参数:breaks
the n+1 cell boundaries (= breaks if that was a vector). These are the nominal breaks, not with the boundary fuzz.
n+1的单元格边界(=breaks,如果这是一个向量)。这是名义的符号,而不是用边界模糊。
参数:counts
n values; for each cell, the number of x[] inside.
n的值,对每个小区,x[]内的数目。
参数:density
values for each bin such that the area under the histogram totals 1. \hat f(x_i ω_i) / f^(x[i] ω[i]), as estimated density values. If all(diff(breaks) == 1), they are the relative frequencies counts/n and in general satisfy ∑_i \hat f(x_i ω_i) (b_{i+1}-b_i) = 1 / sum[i; f^(x[i] ω[i]) (b[i+1]-b[i])] = 1, where b[i] = breaks[i].
各bin中的值,使得根据直方图的总面积1。 \hat f(x_i ω_i)/f^(x[i] ω[i]),估计密度值。如果all(diff(breaks) == 1),他们的相对频率counts/n和一般满足∑_i \hat f(x_i ω_i) (b_{i+1}-b_i) = 1/sum[i; f^(x[i] ω[i]) (b[i+1]-b[i])] = 1,其中b[i]=breaks[i]。
参数:intensities
same as density. Deprecated, but retained for compatibility.
作为density相同。已过时,但保留的兼容性。
参数:mids
the n cell midpoints.
n单元的中点。
参数:xname
a character string with the actual x argument name.
与实际的x参数名称的字符串。
参数:equidist
logical, indicating if the distances between breaks are all the same.
逻辑,指示如果之间的距离breaks都是相同的。
(作者)----------Author(s)----------
Josh Pasek, Assistant Professor of Communication Studies at the University of Michigan (www.joshpasek.com) was responsible for the updates to the hist function necessary to implement weighted counts. The hist.default code from the graphics package on which the current function was based was written by R-core. All modifications are noted in code and the copyright for all original code remains with R-core.
实例----------Examples----------
var1 <- c(1:100)
wgt <- var1/mean(var1)
par(mfrow=c(2, 2))
wtd.hist(var1)
wtd.hist(var1, weight=wgt)
wtd.hist(var1, weight=var1)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|