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

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

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

                                        Draw Function Plots
                                         绘制功能图解

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

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

Draws a curve corresponding to a function over the interval [from, to]. curve can plot also an expression in the variable xname, default x.
绘制一条曲线对应的超过间隔[from, to]功能。 curve也可以绘制在变量xname,默认的x表达。


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


curve(expr, from = NULL, to = NULL, n = 101, add = FALSE,
      type = "l", xname = "x", xlab = xname, ylab = NULL,
      log = NULL, xlim = NULL, ...)

## S3 method for class 'function'
plot(x, y = 0, to = 1, from = y, xlim = NULL, ylab = NULL, ...)



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

参数:expr
The name of a function, or a call or an expression written as a function of x which will evaluate to an object of the same length as x.
函数的名称,或打电话或表达式作为一个功能写x这将评估对象相同的长度为x。


参数:x
a "vectorizing" numeric R function.
“向量化”数字R函数。


参数:y
alias for from for compatibility with plot
别名from兼容性与plot


参数:from, to
the range over which the function will be plotted.
的功能将被绘制的范围。


参数:n
integer; the number of x values at which to evaluate.
整数x值的数量评估。


参数:add
logical; if TRUE add to an already existing plot; if NA start a new plot taking the defaults for the limits and log-scaling of the x-axis from the previous plot.  Taken as FALSE (with a warning if a different value is supplied) if no graphics device is open.
逻辑;如果TRUE添加到一个已经存在的图;如果NA开始一个新的图,从前面的图x轴的限制和日志缩放的默认。作为FALSE(一个警告,如果提供一个不同的值),如果没有图形设备是开放的。


参数:xlim
NULL or a numeric vector of length 2; if non-NULL it provides the defaults for c(from, to) and, unless add = TRUE, selects the x-limits of the plot – see plot.window.
NULL或一个长度为2的数字矢量;如果非NULLc(from, to)提供的默认值,除非add = TRUE,选择图X-极限 - 看到plot.window。


参数:type
plot type: see plot.default.
图类型:看到plot.default。


参数:xname
character string giving the name to be used for the x axis.
字符串要使用的名称为X轴。


参数:xlab, ylab, log, ...
labels and graphical parameters can also be specified as arguments.  See "Details" for the interpretation of the default for log.  For the "function" method of plot, ... can include any of the other arguments of curve, except expr.  
还可以指定标签和图形参数作为参数。见“详细资料”的默认解释为log。 "function"plot方法,...可以包括任何curve其他参数,除了expr。


Details

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

The function or expression expr (for curve) or function x (for plot) is evaluated at n points equally spaced over the range [from, to].  The points determined in this way are then plotted.
功能或表达expr(为curve)或功能x(plot)n点计算平均间隔的范围[from, to]“ 。以这种方式确定的点,然后绘制。

If either from or to is NULL, it defaults to the corresponding element of xlim if that is not NULL.
如果任from或to是NULL,它默认为相应的元素xlim如果不是NULL。

What happens when neither from/to nor xlim specifies both x-limits is a complex story.  For plot(<function>) and for curve(add = FALSE) the defaults are (0, 1).  For curve(add = NA) and curve(add =   TRUE) the defaults are taken from the x-limits used for the previous plot.  (This differs from versions of R prior to 2.14.0.)
会发生什么事时,既不from/to也xlim指定两个X-极限是一个复杂的故事。 plot(<function>)和curve(add = FALSE)默认是(0, 1)。 curve(add = NA)和curve(add =   TRUE)默认是从前面的图中使用的X-极限。 (这不同于之前的R版本2.14.0。)

The value of log is used both to specify the plot axes (unless add = TRUE) and how "equally spaced" is interpreted: if the x component indicates log-scaling, the points at which the expression or function is plotted are equally spaced on log scale.
值log用于指定图轴(除非add = TRUE“”)和“等距”的解释:如果x分量表示日志缩放,点在表达或函数绘制同样对数刻度的间距。

The default value of log is taken from the current plot when add = TRUE, whereas if add = NA the x component is taken from the existing plot (if any) and the y component defaults to linear.  For add = FALSE the default is ""
默认值log从目前的图时,add = TRUE,而如果add = NAx分量是从现有的图(如有)和y分量默认线性。对于add = FALSE默认""

This used to be a quick hack which now seems to serve a useful purpose, but can give bad results for functions which are not smooth.
这是一个快速的破解,现在似乎成为一个有用的目的,但可以给坏的结果,这是不光滑的功能。

For expensive-to-compute expressions, you should use smarter tools.
昂贵计算expressions,你应该使用更聪明的工具。

The way curve handles expr has caused confusion.  It first looks to see if expr is a name (also known as a symbol), in which case it is taken to be the name of a function, and expr is replaced by a call to expr with a single argument with name given by xname.  Otherwise it checks that expr is either a call or an expression, and that it contains a reference to the variable given by xname (using all.vars): anything else is an error.  Then expr is evaluated in an environment which supplies a vector of name given by xname of length n, and should evaluate to an object of length n.  Note that this means that curve(x, ...) is taken as a request to plot a function named x (and it is used as such in the function method for plot).
方式curve处理expr造成混乱。它首先看到expr如果是一个名称(也称为符号),在这种情况下,它采取的是一个函数的名称,expr调用一个<取代X>用与expr给定名称的单一参数。否则,它会检查xname是一个电话或一个表达式,它包含一个变量的引用(使用exprxname):别的是错误的。然后all.vars评估的环境中,它提供了一个向量expr长度xname给定的名称,并应评估对象的长度n。请注意,这意味着n要求绘制函数名为curve(x, ...)(它是用来在x方法function)等。

As from R 2.14.0 the plot method can be called directly as plot.function.
2.14.0从Rplot方法可以直接调用plot.function。


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

A list with components x and y of the points that were  drawn is returned invisibly.
与组件列表x和y绘制点返回无形。


警告----------Warning----------

For historical reasons, add is allowed as an argument to the "function" method of plot, but its behaviour may surprise you.  It is recommended to use add only with curve.
由于历史的原因,add允许作为"function"plot方法的参数,但其行为可能会让你大吃一惊。建议使用add用curve。


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

splinefun for spline interpolation, lines.
splinefun样条插值,lines。


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


plot(qnorm) # default range c(0, 1) is appropriate here,[默认范围C(0,1)是适当的,在这里,]
            # but end values are -/+Inf and so are omitted.[但最终值 -  / + INF,并因此被省略。]
plot(qlogis, main = "The Inverse Logit : qlogis()")
abline(h = 0, v = 0:2/2, lty = 3, col = "gray")

curve(sin, -2*pi, 2*pi, xname = "t")
curve(tan, xname = "t", add = NA,
      main = "curve(tan)  --> same x-scale as previous plot")

op <- par(mfrow = c(2, 2))
curve(x^3 - 3*x, -2, 2)
curve(x^2 - 2, add = TRUE, col = "violet")

## simple and advanced versions, quite similar:[#简单的和先进的版本,颇为相似:]
plot(cos, -pi,  3*pi)
curve(cos, xlim = c(-pi, 3*pi), n = 1001, col = "blue", add = TRUE)

chippy <- function(x) sin(cos(x)*exp(-x/2))
curve(chippy, -8, 7, n = 2001)
plot (chippy, -8, -5)

for(ll in c("", "x", "y", "xy"))
   curve(log(1+x), 1, 100, log = ll,
         sub = paste("log= '", ll, "'", sep = ""))
par(op)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-24 08:39 , Processed in 0.025881 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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