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

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

[复制链接]
发表于 2012-2-16 18:33:58 | 显示全部楼层 |阅读模式
histogram(lattice)
histogram()所属R语言包:lattice

                                        Histograms and Kernel Density Plots
                                         直方图和核密度图

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

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

Draw Histograms and Kernel Density Plots, possibly conditioned on other variables.
绘制直方图和核密度图,可能对其他变量的条件。


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


histogram(x, data, ...)
densityplot(x, data, ...)
## S3 method for class 'formula'[类formula的方法]
histogram(x,
          data,
          allow.multiple, outer = TRUE,
          auto.key = FALSE,
          aspect = "fill",
          panel = lattice.getOption("panel.histogram"),
          prepanel, scales, strip, groups,
          xlab, xlim, ylab, ylim,
          type = c("percent", "count", "density"),
          nint = if (is.factor(x)) nlevels(x)
          else round(log2(length(x)) + 1),
          endpoints = extend.limits(range(as.numeric(x),
                          finite = TRUE), prop = 0.04),
          breaks,
          equal.widths = TRUE,
          drop.unused.levels =
              lattice.getOption("drop.unused.levels"),
          ...,
          lattice.options = NULL,
          default.scales = list(),
          default.prepanel =
              lattice.getOption("prepanel.default.histogram"),
          subscripts,
          subset)

## S3 method for class 'numeric'
histogram(x, data = NULL, xlab, ...)
## S3 method for class 'factor'
histogram(x, data = NULL, xlab, ...)

## S3 method for class 'formula'[类formula的方法]
densityplot(x,
            data,
            allow.multiple = is.null(groups) || outer,
            outer = !is.null(groups),
            auto.key = FALSE,
            aspect = "fill",
            panel = lattice.getOption("panel.densityplot"),
            prepanel, scales, strip, groups, weights,
            xlab, xlim, ylab, ylim,
            bw, adjust, kernel, window, width, give.Rkern,
            n = 50, from, to, cut, na.rm,
            drop.unused.levels =
                lattice.getOption("drop.unused.levels"),
            ...,
            lattice.options = NULL,
            default.scales = list(),
            default.prepanel =
                lattice.getOption("prepanel.default.densityplot"),
            subscripts,
            subset)
## S3 method for class 'numeric'
densityplot(x, data = NULL, xlab, ...)

do.breaks(endpoints, nint)



参数----------Arguments----------

参数:x
The object on which method dispatch is carried out.  For the formula method, x can be a formula of the form ~ x | g1 * g2 * ..., indicating that histograms or kernel density estimates of the x variable should be produced conditioned on the levels of the (optional) variables g1, g2, ....  x should be numeric (or possibly a factor in the case of histogram), and each of g1, g2, ... should be either factors or shingles.  As a special case, the right hand side of the formula can contain more than one term separated by "+" signs (e.g., ~ x1 +     x2 | g1 * g2).  What happens in this case is described in the documentation for xyplot.  Note that in either form, all the terms in the formula must have the same length after evaluation.  For the numeric and factor methods, x is the variable whose histogram or Kernel density estimate is drawn. Conditioning is not allowed in these cases.  
对象的方法调度进行。为formula方法,x可以形式~ x | g1 * g2 * ...公式,显示直方图或x变量核密度估计,应当制作水平的制约(可选的)变量g1,g2.... x应该是数值(或可能的情况下的一个因素histogram),每个g1,g2,...应该是任何因素或带状疱疹。作为一个特殊的情况下,右侧的公式可以包含一个以上的长期分离“+”符号(例如,~ x1 +     x2 | g1 * g2)。在这种情况下,会发生什么文档中所描述的xyplot。请注意,无论是哪种形式,公式中的所有条款必须有评估后的长度相同。为numeric和factor方法,x是绘制的直方图或核密度估计的变量。不允许在这些情况下,空调。


参数:data
For the formula method, an optional data source (usually a data frame) in which variables are to be evaluated (see xyplot for details).  data should not be specified for the other methods, and is ignored with a warning if it is.  
formula方法,一个可选的数据源(通常是一个数据框)的变量进行评估(见xyplot细节)。 data不应该被指定为其他方法,忽略警告,如果它是。


参数:type
A character string indicating the type of histogram that is to be drawn.  "percent" and "count" give relative frequency and frequency histograms respectively, and can be misleading when breakpoints are not equally spaced. "density" produces a density histogram.  type defaults to "density" when the breakpoints are unequally spaced or breaks = NULL, and to "percent" otherwise.  
一个字符串,表示要绘制直方图类型。 "percent"和"count"给相对频率和频率直方图,可以误导断点时不等距。 "density"产生一个密度直方图。 type默认"density"当断点不均匀间隔或breaks = NULL,"percent"否则。


参数:nint
An integer specifying the number of histogram bins, applicable only when breaks is unspecified or NULL in the call. Ignored when the variable being plotted is a factor.  
一个整数,指定直方图箱,适用只有当breaks是不确定的或NULL在通话。正在绘制的变量是一个因素时,忽略。


参数:endpoints
A numeric vector of length 2 indicating the range of x-values that is to be covered by the histogram.  This applies only when breaks is unspecified and the variable being plotted is not a factor.  In do.breaks, this specifies the interval that is to be divided up.  
向量的长度的数字2表示x值是由直方图覆盖范围。这适用于只有当breaks是不确定的和绘制的变量的存在,是不是一个因素。这在do.breaks,指定的时间间隔是被瓜分了。


参数:breaks
Usually a numeric vector of length (number of bins + 1) defining the breakpoints of the bins.  Note that when breakpoints are not equally spaced, the only value of type that makes sense is density. When unspecified, the default is to use  <RE>       breaks = seq_len(1 + nlevels(x)) - 0.5     </PRE> when x is a factor, and  <RE>       breaks = do.breaks(endpoints, nint)     </PRE> otherwise.  Breakpoints calculated in such a manner are used in all panels. Other values of breaks are possible, in which case they affect the display in each panel differently.  A special value of breaks is NULL, in which case the number of bins is determined by nint and then breakpoints are chosen according to the value of equal.widths.  Other valid values of breaks are those of the breaks argument in hist.  This allows specification of breaks as an integer giving the number of bins (similar to nint), as a character string denoting a method, or as a function.
一般一个长度为数字向量(箱数+ 1)定义的垃圾箱中断点。请注意断点时不等距的,type,有意义的唯一价值是密度。如果未指定,默认的是使用<RE>截断= seq_len(1 + nlevels(X)) -  0.5 </ pre>当x是一个因素,<RE>截断= do.breaks(端点, NINT)</ pre>否则。以这种方式计算的断点用于在所有面板。 breaks其他值是可能的,在这种情况下,他们每个面板的显示不同影响。一种特殊的价值breaksNULL,在这种情况下,垃圾箱的数量确定nint然后根据equal.widths价值选择断点。 breaks其他有效值是那些在breakshist参数。这使得规范breaks作为一个整数,箱数(类似nint),作为一个字符串表示的方法,或作为一个功能。


参数:equal.widths
A logical flag, relevant only when breaks=NULL.  If TRUE, equally spaced bins will be selected, otherwise, approximately equal area bins will be selected (typically producing unequally spaced breakpoints).  
只有当一个逻辑标志,有关breaks=NULL。如果TRUE,等距的垃圾箱将被选中,否则,面积约等于箱将选择(通常间隔不等的断点)。


参数:n
Integer, giving the number of points at which the kernel density is to be evaluated.  Passed on as an argument to density.  
整数,给点时的内核密度进行评估。对作为density参数传递。


参数:panel
A function, called once for each panel, that uses the packet (subset of panel variables) corresponding to the panel to create a display. The default panel functions panel.histogram and panel.densityplot are documented separately, and have arguments that can be used to customize its output in various ways. Such arguments can usually be directly supplied to the high-level function.  
一次,要求每个小组的一个功能,使用包(面板变量的子集)对应创建一个显示面板。默认面板功能panel.histogram和panel.densityplot分开记录,并可以用各种方式来定制其输出的参数。这种论调,通常可以直接提供给高层次的功能。


参数:allow.multiple, outer
See xyplot.  
看到xyplot。


参数:auto.key
See xyplot.  
看到xyplot。


参数:aspect
See xyplot.  
看到xyplot。


参数:prepanel
See xyplot.  
看到xyplot。


参数:scales
See xyplot.  
看到xyplot。


参数:strip
See xyplot.  
看到xyplot。


参数:groups
See xyplot.  Note that the default panel function for histogram does not support grouped displays, whereas the one for densityplot does.  
看到xyplot。注意histogram不支持分组显示,默认的面板功能,而一个densityplot。


参数:xlab, ylab
See xyplot.  
看到xyplot。


参数:xlim, ylim
See xyplot.  
看到xyplot。


参数:drop.unused.levels
See xyplot.  
看到xyplot。


参数:lattice.options
See xyplot.  
看到xyplot。


参数:default.scales
See xyplot.  
看到xyplot。


参数:subscripts
See xyplot.  
看到xyplot。


参数:subset
See xyplot.  
看到xyplot。


参数:default.prepanel
Fallback prepanel function.  See xyplot.  
后备prepanel功能。看到xyplot。


参数:weights
numeric vector of weights for the density calculations, evaluated in the non-standard manner used for groups and terms in the formula, if any.  If this is specified, it is subsetted using subscripts inside the panel function to match it to the corresponding x values.  At the time of writing, weights do not work in conjunction with an extended formula specification (this is not too hard to fix, so just bug the maintainer if you need this feature).  
groups公式中的条款使用的非标准的方式计算的密度计算重量,数值向量,如果有的话。如果这是指定的,它是子集使用subscripts面板内的功能来匹配相应的x值。在编写时,weights不使用扩展的公式规范(这不是太难解决,所以只是错误的维护者,如果您需要此功能)结合。


参数:bw, adjust, width
Arguments controlling bandwidth.  Passed on as arguments to density.  
参数控制带宽。通过density参数。


参数:kernel, window
The choice of kernel.  Passed on as arguments to density.   
内核的选择。通过density参数。


参数:give.Rkern
Logical flag, passed on as argument to density. This argument is made available only for ease of implementation, and will produce an error if TRUE.  
逻辑的标志,通过作为参数density。这种说法仅适用于易于实现,将产生一个错误,如果TRUE。


参数:from, to, cut
Controls range over which density is evaluated.  Passed on as arguments to density.  
控制的范围,密度评估。通过density参数。


参数:na.rm
Logical flag specifying whether NA values should be ignored. Passed on as argument to density, but unlike in density, the default is TRUE.  
逻辑标志,指定是否NA值应该被忽略。通过作为参数density,但不像在density,默认的是TRUE。


参数:...
Further arguments.  See corresponding entry in xyplot for non-trivial details.   
进一步的论据。 xyplot非琐碎的细节,请参见相应的条目。


Details

详情----------Details----------

histogram draws Conditional Histograms, and densityplot draws Conditional Kernel Density Plots.  The default panel function uses the density function to compute the density estimate, and all arguments accepted by density can be specified in the call to densityplot to control the output. See documentation of density for details.  Note that the default value of the argument n of density is changed to 50.
histogram绘制条件直方图,densityplot提请有条件的内核密度图。默认的面板功能使用density函数计算密度估计,接受density可以指定在调用densityplot来控制输出的所有参数。详情请参阅文件density。需要注意的是参数的默认值ndensity改为50。

These and all other high level Trellis functions have several arguments in common. These are extensively documented only in the help page for xyplot, which should be consulted to learn more detailed usage.
这些和所有其他高层次网格功能有几个共同的参数。这些被广泛记载,只有在帮助页xyplot,应谘询,以了解更详细的用法。

do.breaks is an utility function that calculates breakpoints given an interval and the number of pieces to break it into.
do.breaks是一个实用功能,给定的时间间隔和分解成件数计算的断点。


值----------Value----------

An object of class "trellis". The update method can be used to update components of the object and the print method (usually called by default) will plot it on an appropriate plotting device.
对象类"trellis"。 update方法可以用来更新的对象和print方法(通常称为默认情况下),将适当的绘图设备上绘制它的组成部分。


注意----------Note----------

The form of the arguments accepted by the default panel function panel.histogram is different from that in S-PLUS. Whereas S-PLUS calculates the heights inside histogram and passes only the breakpoints and the heights to the panel function, lattice simply passes along the original variable x along with the breakpoints. This approach is more flexible; see the example below with an estimated density superimposed over the histogram.
默认面板功能panel.histogram接受参数的形式是不同的,S-PLUS。鉴于,S-PLUS里面histogram计算的高度,只通过断点和高度的面板功能,lattice只需通过沿原始变量x随着断点。这种方法更加灵活;看到下面的例子中,叠加在直方图估计密度。


作者(S)----------Author(s)----------


Deepayan Sarkar <a href="mailtoeepayan.Sarkar@R-project.org">Deepayan.Sarkar@R-project.org</a>



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

Visualization with R, Springer. http://lmdvr.r-forge.r-project.org/

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

xyplot, panel.histogram, density, panel.densityplot, panel.mathdensity, Lattice
xyplot,panel.histogram,density,panel.densityplot,panel.mathdensity,Lattice


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


require(stats)
histogram( ~ height | voice.part, data = singer, nint = 17,
          endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 1,
          xlab = "Height (inches)")

histogram( ~ height | voice.part, data = singer,
          xlab = "Height (inches)", type = "density",
          panel = function(x, ...) {
              panel.histogram(x, ...)
              panel.mathdensity(dmath = dnorm, col = "black",
                                args = list(mean=mean(x),sd=sd(x)))
          } )

densityplot( ~ height | voice.part, data = singer, layout = c(2, 4),  
            xlab = "Height (inches)", bw = 5)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 14:57 , Processed in 0.033839 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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