命令 "plot(qnorm)" 在 R 中如何工作?
How does the command "plot(qnorm)" work in R?
当我 运行 命令 plot(qnorm)
时,它会产生下图:
但我不明白该命令是如何生成图表的?
qnorm
是一个函数,所以寻找一个遵循plot.function
的S3约定的函数是有见地的。如果你阅读帮助,你会看到这个函数:
Draws a curve corresponding to a function over the interval
'[from, to]'. 'curve' can plot also an expression in the variable
'xname', default 'x'.
由于您没有指定范围,在帮助文档的下方,它指出:
What happens when neither 'from'/'to' nor 'xlim' specifies both
x-limits is a complex story. For 'plot()' 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.)
(为强调而添加的突出显示)。
因此,您对 plot(qnorm)
的调用类似于 curve(qnorm, from = 0, to = 1)
每个 plot.function
。
当我 运行 命令 plot(qnorm)
时,它会产生下图:
但我不明白该命令是如何生成图表的?
qnorm
是一个函数,所以寻找一个遵循plot.function
的S3约定的函数是有见地的。如果你阅读帮助,你会看到这个函数:
Draws a curve corresponding to a function over the interval '[from, to]'. 'curve' can plot also an expression in the variable 'xname', default 'x'.
由于您没有指定范围,在帮助文档的下方,它指出:
What happens when neither 'from'/'to' nor 'xlim' specifies both x-limits is a complex story. For 'plot()' 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.)
(为强调而添加的突出显示)。
因此,您对 plot(qnorm)
的调用类似于 curve(qnorm, from = 0, to = 1)
每个 plot.function
。