找回密码
 注册
查看: 25940|回复: 0

R语言:hist()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 17:32:01 | 显示全部楼层 |阅读模式
hist(graphics)
hist()所属R语言包:graphics

                                        Histograms
                                         直方图

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

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.
通用函数hist计算一个给定的数据值的直方图。 plot=TRUE如果类"histogram"对象plot.histogram绘制,然后才返回。


用法----------Usage----------


hist(x, ...)

## Default S3 method:[默认方法]
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, warn.unused = TRUE, ...)



参数----------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的兼容性的别名。


参数: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.
逻辑或字符。此外,借鉴条形顶部的标签,如果没有FALSE;看到plot.histogram。


参数:nclass
numeric (integer).  For S(-PLUS) compatibility only, nclass is equivalent to breaks for a scalar or character argument.   
数字(整数)。只为S-PLUS的兼容性,nclass相当于breaks一个标量或字符参数。


参数:warn.unused
logical.  If plot=FALSE and  warn.unused=TRUE, a warning will be issued when graphical parameters are passed to hist.default().
逻辑。如果plot=FALSE和warn.unused=TRUE,警告发出时,图形的参数被传递到hist.default()。


参数:...
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 counts in the cells defined by breaks.  Thus the height of a rectangle is proportional to the 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.
非等间隔符的默认是给剧情的区域之一,在长方形的面积是小部分的单元中的数据点。

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手段,包括最高的“。

A numerical tolerance of 1e-7 times the median bin size is applied when counting entries on the edges of bins.  This is not included in the reported breaks nor (as from R 2.11.0) in the calculation of density.
一个数值公差1e-7倍中位数的bin大小计数时箱的边缘上的条目。这不包括在报道breaks也不在计算density的(如从R 2.11.0)。

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 integers; for each cell, the number of x[] inside.
n整数,每个单元,x[]里面。


参数:density
values f^(x[i]), as estimated density values. If all(diff(breaks) == 1), they are the relative frequencies counts/n and in general satisfy sum[i; f^(x[i])       (b[i+1]-b[i])] = 1, where b[i] = breaks[i].
值f^(x[i]),估计密度值。如果all(diff(breaks) == 1),它们的相对频率counts/n一般满足sum[i; f^(x[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距离都是一样的。


参考文献----------References----------

The New S Language. Wadsworth & Brooks/Cole.
Modern Applied Statistics with S.  Springer.

参见----------See Also----------

nclass.Sturges, stem, density,  truehist in package MASS.
nclass.Sturges,stem,density,truehist在包MASS。

Typical plots with vertical bars are not histograms.  Consider barplot or plot(*, type = "h") for such bar plots.
典型图与竖线不直方图。考虑这样的条形图barplot或plot(*, type = "h")。


举例----------Examples----------


op <- par(mfrow=c(2, 2))
hist(islands)
utils::str(hist(islands, col="gray", labels = TRUE))

hist(sqrt(islands), breaks = 12, col="lightblue", border="pink")
##-- For non-equidistant breaks, counts should NOT be graphed unscaled:[# - 非等距截断,计数不应该被绘制未缩放:]
r <- hist(sqrt(islands), breaks = c(4*0:5, 10*3:5, 70, 100, 140),
          col='blue1')
text(r$mids, r$density, r$counts, adj=c(.5, -.5), col='blue3')
sapply(r[2:3], sum)
sum(r$density * diff(r$breaks)) # == 1[== 1]
lines(r, lty = 3, border = "purple") # -&gt; lines.histogram(*)[ - > lines.histogram(*)]
par(op)

require(utils) # for str[为STR]
str(hist(islands, breaks=12, plot= FALSE)) #-&gt; 10 (~= 12) breaks[ - > 10(= 12)截断]
str(hist(islands, breaks=c(12,20,36,80,200,1000,17000), plot = FALSE))

hist(islands, breaks=c(12,20,36,80,200,1000,17000), freq = TRUE,
     main = "WRONG histogram") # and warning[和警告]

require(stats)
set.seed(14)
x <- rchisq(100, df = 4)

## Comparing data with a model distribution should be done with qqplot()![#模型分布比较数据应做与qqplot()!]
qqplot(x, qchisq(ppoints(x), df = 4)); abline(0,1, col = 2, lty = 2)

## if you really insist on using hist() ... :[#如果你真的坚持使用hist()... :]
hist(x, freq = FALSE, ylim = c(0, 0.2))
curve(dchisq(x, df = 4), col = 2, lty = 2, lwd = 2, add = TRUE)


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-22 19:48 , Processed in 0.023330 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表