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

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

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

                                        Compactly Display the Structure of an Arbitrary R Object
                                         紧显示任意R对象的结构

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

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

Compactly display the internal structure of an R object, a diagnostic function and an alternative to summary (and to some extent, dput).  Ideally, only one line for each "basic" structure is displayed.  It is especially well suited to compactly display the (abbreviated) contents of (possibly nested) lists.  The idea is to give reasonable output for any R object.  It calls args for (non-primitive) function objects.
紧显示R对象的内部结构,诊断功能和替代summary(在一定程度上,dput)。理想的情况下,为每一个“基本”的结构中只有一个行显示。它特别适合于紧凑显示的内容(略)(可能是嵌套的)名单。的想法是合理的输出给任何R对象。它呼吁args(非原始)函数对象。

strOptions() is a convenience function for setting options(str = .), see the examples.
strOptions()设置options(str = .),看到的例子是方便的功能。


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


str(object, ...)

## S3 method for class 'data.frame'
str(object, ...)

## Default S3 method:[默认方法]
str(object, max.level = NA,
    vec.len  = strO$vec.len, digits.d = strO$digits.d,
    nchar.max = 128, give.attr = TRUE,
    give.head = TRUE, give.length = give.head,
    width = getOption("width"), nest.lev = 0,
    indent.str = paste(rep.int(" ", max(0, nest.lev + 1)),
                       collapse = ".."),
    comp.str="$ ", no.list = FALSE, envir = baseenv(),
    strict.width = strO$strict.width,
    formatNum = strO$formatNum, list.len = 99, ...)

strOptions(strict.width = "no", digits.d = 3, vec.len = 4,
           formatNum = function(x, ...)
                       format(x, trim=TRUE, drop0trailing=TRUE, ...))



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

参数:object
any R object about which you want to have some information.
任何想要有一些信息的R对象。


参数:max.level
maximal level of nesting which is applied for displaying nested structures, e.g., a list containing sub lists. Default NA: Display all nesting levels.
嵌套其中的最高水平,显示嵌套的结构,例如,一个列表,其中包含子列表。默认情况下不适用:显示所有的嵌套级别。


参数:vec.len
numeric (>= 0) indicating how many "first few" elements are displayed of each vector.  The number is multiplied by different factors (from .5 to 3) depending on the kind of vector.  Defaults to the vec.len component of option "str" (see options) which defaults to 4.
数值(> = 0),表示多少“的前几个”显示每个向量元素。数量乘以不同的因素,取决于向量(从0.5至3)。 vec.len选项的组件默认"str"(options)默认为4。


参数:digits.d
number of digits for numerical components (as for print).  Defaults to the digits.d component of option "str" which defaults to 3.
数值组件的数字(print作为)。 digits.d选项的组件默认"str"默认为3。


参数:nchar.max
maximal number of characters to show for character strings.  Longer strings are truncated, see longch example below.
character字符串显示的最大字符数。更长的字符串被截断,见下面的longch例如。


参数:give.attr
logical; if TRUE (default), show attributes as sub structures.
逻辑;如果TRUE(默认),显示子结构的属性。


参数:give.length
logical; if TRUE (default), indicate length (as [1:...]).
逻辑;如果TRUE(默认),表明长度([1:...])。


参数:give.head
logical; if TRUE (default), give (possibly abbreviated) mode/class and length (as <type>[1:...]).
逻辑;如果TRUE(默认),(可能略)模式/类和长度(<type>[1:...])。


参数:width
the page width to be used.  The default is the currently active options("width"); note that this has only a weak effect, unless strict.width is not "no".
要使用的页面宽度。默认是目前活跃options("width");注,这只是一个微弱的作用,除非strict.width不"no"。


参数:nest.lev
current nesting level in the recursive calls to str.
在当前的嵌套级别的递归调用str。


参数:indent.str
the indentation string to use.
使用压痕字符串。


参数:comp.str
string to be used for separating list components.
字符串用于分隔列表组件。


参数:no.list
logical; if true, no "list of ..." nor the class are printed.
逻辑; ......如果属实,没有名单,也不是一类印。


参数:envir
the environment to be used for promise (see delayedAssign) objects only.
承诺(见delayedAssign)对象只可用于环境。


参数:strict.width
string indicating if the width argument's specification should be followed strictly, one of the values c("no", "cut", "wrap"). Defaults to the strict.width component of option "str" (see options) which defaults to "no" for back compatibility reasons; "wrap" uses strwrap(*, width=width) whereas "cut" cuts directly to width.  Note that a small vec.length may be better than setting strict.width = "wrap".
字符串,指示如果width参数的规范,应严格遵守,值c("no", "cut", "wrap")之一。默认选项的组件strict.width "str"(options)默认为"no"回兼容性的原因;"wrap"使用strwrap(*, width=width)而 "cut"width直接削减。请注意,一个小的vec.length可能比设置strict.width = "wrap"。


参数:formatNum
a function such as format for formatting numeric vectors.  It defaults to the formatNum component of option "str", see &ldquo;Usage&rdquo; of strOptions() above, which is almost back compatible to R <= 2.7.x, however, using formatC may be slightly better.
如format格式化数字向量的功能。它默认为formatNum选项的组件"str",strOptions()以上,这几乎是回到兼容的R <= 2.7.x见“用法”,然而,使用formatC可能稍好。


参数:list.len
numeric; maximum number of list elements to display within a level.
数字列表元素的最大数量,显示在一个水平。


参数:...
potential further arguments (required for Method/Generic reasons).
潜在的方法/通用原因需要进一步的论据。


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

str does not return anything, for efficiency reasons. The obvious side effect is output to the terminal.
str不返回任何东西,因为效率的原因。最明显的副作用是输出到终端。


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


Martin Maechler <a href="mailto:maechler@stat.math.ethz.ch">maechler@stat.math.ethz.ch</a> since 1990.




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

ls.str for listing objects with their structure; summary, args.
ls.str房源的对象,它们的结构;summary,args。


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


require(stats); require(grDevices); require(graphics)
## The following examples show some of 'str' capabilities[#下面的例子显示一些“STR”功能]
str(1:12)
str(ls)
str(args) #- more useful than  args(args) ![ -  ARGS(参数)多有用!]
str(freeny)
str(str)
str(.Machine, digits.d = 20)# extra digits for identification of binary numbers[额外的数字识别的二进制数]
str( lsfit(1:9,1:9))
str( lsfit(1:9,1:9), max.level = 1)
str( lsfit(1:9,1:9), width = 60, strict.width = "cut")
str( lsfit(1:9,1:9), width = 60, strict.width = "wrap")
op &lt;- options(); str(op) # save first;[救人第一;]
                         # otherwise internal options() is used.[否则内部选项()。]
need.dev <-
  !exists(".Device") || is.null(.Device) || .Device == "null device"
{ if(need.dev) postscript()
  str(par())
  if(need.dev) graphics.off()
}
ch <- letters[1:12]; is.na(ch) <- 3:5
str(ch) # character NA's[字符不适用]

str(list(a="A", L = as.list(1:100)), list.len = 9)
nchar(longch <- paste(rep(letters,100), collapse=""))
str(longch)
str(longch, nchar.max = 52)

str(longch, strict.width = "wrap")

## Settings for narrow transcript :[#设置窄成绩单:]
op <- options(width = 60,
              str = strOptions(strict.width = "wrap"))
str(lsfit(1:9,1:9))
str(options())
## reset to previous:[#重置以前的:]
options(op)



str(quote( { A+B; list(C,D) } ))



## S4 classes :[#S4类:]
require(stats4)
x <- 0:10; y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)
ll <- function(ymax=15, xh=6)
      -sum(dpois(y, lambda=ymax/(1+x/xh), log=TRUE))
fit <- mle(ll)
str(fit)


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-3 04:04 , Processed in 0.021931 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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