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

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

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

                                        Functions to Interact with Lattice Plots
                                         功能,以互动的格子图

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

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

The classic Trellis paradigm is to plot the whole object at once, without the possibility of interacting with it afterwards.  However, by keeping track of the grid viewports where the panels and strips are drawn, it is possible to go back to them afterwards and enhance them one panel at a time.  These functions provide convenient interfaces to help in this.  Note that these are still experimental and the exact details may change in future.
经典的格子范式是无事后与它相互作用的可能性,绘制整个对象一次。然而,跟踪板和钢带绘制网格的视口,它是可以回去后他们,提高他们一时间在面板。这些功能提供了方便的接口,以帮助在此。请注意,这些都是仍处于试验阶段的具体细节可能在未来改变。


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


panel.identify(x, y = NULL,
               subscripts = seq_along(x),
               labels = subscripts,
               n = length(x), offset = 0.5,
               threshold = 18, ## in points, roughly 0.25 inches
               panel.args = trellis.panelArgs(),
               ...)
panel.identify.qqmath(x, distribution, groups, subscripts, labels,
                      panel.args = trellis.panelArgs(),
                      ...)
panel.identify.cloud(x, y, z, subscripts,
                     perspective, distance,
                     xlim, ylim, zlim,
                     screen, R.mat, aspect, scales.3d,
                     ...,
                     panel.3d.identify,
                     n = length(subscripts),
                     offset = 0.5,
                     threshold = 18,
                     labels = subscripts,
                     panel.args = trellis.panelArgs())
panel.link.splom(threshold = 18, verbose = getOption("verbose"), ...)
panel.brush.splom(threshold = 18, verbose = getOption("verbose"), ...)


trellis.vpname(name = c("position", "split", "split.location", "toplevel",
                        "figure", "panel", "strip", "strip.left",
                        "legend", "legend.region", "main", "sub",
                        "xlab", "ylab", "xlab.top", "ylab.right", "page"),
               column, row,
               side = c("left", "top", "right", "bottom", "inside"),
               clip.off = FALSE, prefix)
trellis.grobname(name,
                 type = c("", "panel", "strip", "strip.left",
                          "key", "colorkey"),
                 group = 0,
                 which.given = lattice.getStatus("current.which.given",
                                                 prefix = prefix),
                 which.panel = lattice.getStatus("current.which.panel",
                                                 prefix = prefix),
                 column = lattice.getStatus("current.focus.column",
                                            prefix = prefix),
                 row = lattice.getStatus("current.focus.row",
                                         prefix = prefix),
                 prefix = lattice.getStatus("current.prefix"))
trellis.focus(name, column, row, side, clip.off,
              highlight = interactive(), ..., prefix,
              guess = TRUE, verbose = getOption("verbose"))
trellis.switchFocus(name, side, clip.off, highlight, ..., prefix)
trellis.unfocus()
trellis.panelArgs(x, packet.number)



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

参数:x, y, z
variables defining the contents of the panel.  In the case of trellis.panelArgs, a "trellis" object.  
变量定义面板的内容。在trellis.panelArgs,"trellis"对象的情况。


参数:n
the number of points to identify by default (overridden by a right click)  
默认情况下,确定的点数(通过右键重写)


参数:subscripts
an optional vector of integer indices associated with each point. See details below.  
与每个点相关联的整数指数可选的向量。详见下文。


参数:labels
an optional vector of labels associated with each point.  Defaults to subscripts  
每个点的标签可选的向量。 subscripts默认


参数:distribution, groups
typical panel arguments of panel.qqmath.  These will usually be obtained from panel.args  
panel.qqmath典型的面板参数。这些通常会获得从panel.args


参数:offset
the labels are printed either below, above, to the left or to the right of the identified point, depending on the relative location of the mouse click. The offset specifies (in "char" units) how far from the identified point the labels should be printed.  
标签印刷,上面,向左或确定点的权利,上点击鼠标的相对位置而定。 offset指定(“char”的单位)如何确定点的标签应印。


参数:threshold
threshold in grid's "points" units. Points further than these from the mouse click position are not considered  
在网格的"points"单位的门槛。不考虑点从鼠标点击的位置,进一步


参数:panel.args
list that contains components names x (and usually y), to be used if x is missing.  Typically, when called after trellis.focus, this would appropriately be the arguments passed to that panel.  
组件名称列表,其中包含x(和通常是y),将用于x如果丢失。通常情况下,后trellis.focus调用时,这将适当的参数传递给该面板。

arguments as passed to panel.cloud.  These are required to recompute the relevant three-dimensional projections in panel.identify.cloud.  
参数传递panel.cloud。这些都需要重新计算相关的三维panel.identify.cloud预测。


参数:panel.3d.identify
the function that is responsible for the actual interaction once the data rescaling and rotation computations have been done.  By default, an internal function similar to panel.identify is used.  
已经完成的功能是负责一次的数据重新缩放和旋转计算的实际互动。默认情况下,内部功能类似panel.identify使用。


参数:name
A character string indicating which viewport or grob we are looking for.  Although these do not necessarily provide access to all viewports and grobs created by a lattice plot, they cover most of the ones that end-users may find interesting.  trellis.vpname and trellis.focus deal with viewport names only, and only accept the values explicitly listed above. trellis.grobname is meant to create names for grobs, and can currently accept any value.  If name, as well as column and row is missing in a call to trellis.focus, the user can click inside a panel (or an associated strip) to focus on that panel.  Note however that this assumes equal width and height for each panel, and may not work when this is not true.  When name is "panel", "strip", or "strip.left", column and row must also be specified.  When name is "legend", side must also be specified.  
视口或GROB我们正在寻找一个字符串,指示。虽然这些不一定提供访问所有视口和由晶格图创建grobs,他们包括大多数的最终用户可能会发现有趣的。 trellis.vpname和trellis.focus视口的名称交易,只接受上面明确列出的值。 trellis.grobname为了创建为grobs名称,目前可以接受任何价值。如果name,以及column和row缺少调用trellis.focus,用户可以点击面板(或相关条)内把重点放在面板。但是请注意,这个假设等于为每个面板的宽度和高度,可能无法正常工作时,这是不正确的。当name是"panel","strip"或"strip.left",column和row也必须被指定。当name是"legend",side也必须被指定。


参数:column, row
integers, indicating position of the panel or strip that should be assigned focus in the Trellis layout. Rows are usually calculated from the bottom up, unless the plot was created with as.table=TRUE  
整数,显示面板或带的位置应分配在网格布局的重点。行通常从下往上计算,除非图as.table=TRUE创建


参数:guess
logical.  If TRUE, and the display has only one panel, that panel will be automatically selected by a call to trellis.focus.  
逻辑。如果TRUE,显示只有一个面板,面板将自动被调用,以trellis.focus选择。


参数:side
character string, relevant only for legends (i.e., when name="legend"), indicating their position.  Partial specification is allowed, as long as it is unambiguous.  
字符串,只为传说有关(即当name="legend"),表明自己的立场。部分规范是允许的,只要它是明确的。


参数:clip.off
logical, whether clipping should be off, relevant when name is "panel" or "strip".  This is necessary if axes are to be drawn outside the panel or strip.  Note that setting clip.off=FALSE does not necessarily mean that clipping is on; that is determined by conditions in effect during printing.  
逻辑,剪裁是否应该关闭,相关时name是"panel"或"strip"。如果面板或带外绘制轴,这是必要的。请注意,设置clip.off=FALSE并不一定意味着,裁剪,效果在印刷条件决定的。


参数:type
A character string specifying whether the grob is specific to a particular panel or strip.  When type is "panel", "strip", or "strip.left", information about the panel is added to the grob name.  
指定一个字符串是否的GROB是具体到某个特定的面板或带。当type是"panel","strip"或"strip.left",面板的信息被添加到GROB名称。


参数:group
An integer specifying whether the grob is specific to a particular group within the plot.  When group is greater than zero, information about the group is added to the grob name.  
一个整数,指定是否的GROB是具体图特别组内。当group是大于零,有关组的信息添加的GROB名称。


参数:which.given, which.panel
integers, indicating which conditional variable is being represented (within a strip) and the current levels of the conditional variables.  When which.panel has length greater than 1, and the type is "strip" or "strip.left", information about the conditional variable is added to the grob name.  
整数,表示条件变量正在代表(内带)和条件变量的现有水平。当which.panel长度大于1,type是"strip"或"strip.left",条件变量的信息添加到GROB名称。


参数:prefix
A character string acting as a prefix identifying the plot of a "trellis" object, primarily used to distinguish otherwise equivalent viewports in different plots. This only becomes relevant when a particular page is occupied by more than one plot.  Defaults to the value appropriate for the last "trellis" object printed, as determined by the prefix argument in print.trellis.  Users should not usually need to supply a value for this argument except to interact with an existing plot other than the one plotted last.  For switchFocus, ignored except when it does not match the prefix of the currently active plot, in which case an error occurs.  
一个字符串,作为确定"trellis"对象主要是用来区分不同的图,否则相当于视口中,图的前缀。这不仅成为有关一个特定的页面时占用超过一个图。默认为适当的值,最后"trellis"对象打印,prefixprint.trellis参数确定。用户不应通常需要为这一论点提供一个值,最后除了互动以外的其他现有的图策划。 switchFocus,但它不符合目前活跃的图,在这种情况下,发生错误的前缀时忽略。


参数:highlight
logical, whether the viewport being assigned focus should be highlighted.  For trellis.focus, the default is TRUE in interactive mode, and trellis.switchFocus by default preserves the setting currently active.  
应当强调的逻辑,视口是否被分配的焦点。 trellis.focus,默认的是TRUE在交互模式下,和trellis.switchFocus默认情况下,保留设置当前活动。


参数:packet.number
integer, which panel to get data from.  See packet.number for details on how this is calculated  
整数,其中面板获取数据。看到packet.number这是如何计算的细节


参数:verbose
whether details  will be printed  
是否将打印细节


参数:...
For panel.identify.qqmath, extra parameters are passed on to panel.identify.  For panel.identify, extra arguments are treated as graphical parameters and are used for labelling.  For trellis.focus and trellis.switchFocus, these are used (in combination with lattice.options) for highlighting the chosen viewport if so requested.  Graphical parameters can be supplied for panel.link.splom.  
panel.identify.qqmath,额外的参数传递到panel.identify。 panel.identify,额外的参数被视为图形的参数,并使用标签。 trellis.focus和trellis.switchFocus,这些都是用来(在与lattice.options组合)突出选择视口,若有要求。 panel.link.splom可提供图形参数。


Details

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

panel.identify is similar to identify.  When called, it waits for the user to identify points (in the panel being drawn) via mouse clicks.  Clicks other than left-clicks terminate the procedure.  Although it is possible to call it as part of the panel function, it is more typical to use it to identify points after plotting the whole object, in which case a call to trellis.focus first is necessary.
panel.identify是identify。当被调用时,它会等待用户通过鼠标点击确定点(在正在起草的面板)。点击左点击以外终止程序。虽然它是可以把它作为面板功能的一部分,这是比较典型的,用它来确定点后,绘制整个对象,在这种情况下,调用一个trellis.focus首先是必要的。

panel.link.splom is meant for use with splom, and requires a panel to be chosen using trellis.focus before it is called.  Clicking on a point causes that and the corresponding proections in other pairwise scatter plots to be highlighted. panel.brush.splom is a (misnamed) alias for panel.link.splom, retained for back-compatibility.
panel.link.splom是使用splom,并要求使用trellis.focus之前它被称为一个被选择的面板。点击一个点上,导致其他成对的散点图,并在相应的proections加以强调。 panel.brush.splom是panel.link.splom,保留向后兼容性(名不副实)别名。

panel.identify.qqmath is a specialized wrapper meant for use with the display produced by qqmath. panel.identify.qqmath is a specialized wrapper meant for use with the display produced by cloud.  It would be unusual to call them except in a context where default panel function arguments are available through trellis.panelArgs (see below).
panel.identify.qqmath与使用qqmath显示意味着一个专门的包装。 panel.identify.qqmath与使用cloud显示意味着一个专门的包装。这将是不寻常的呼吁他们除上下文默认面板功能参数可通过trellis.panelArgs(见下文)。

One way in which panel.identify etc. are different from identify is in how it uses the subscripts argument.  In general, when one identifies points in a panel, one wants to identify the origin in the data frame used to produce the plot, and not within that particular panel.  This information is available to the panel function, but only in certain situations.  One way to ensure that subscripts is available is to specify subscripts = TRUE in the high level call such as xyplot. If subscripts is not explicitly specified in the call to panel.identify, but is available in panel.args, then those values will be used.  Otherwise, they default to seq_along(x).  In either case, the final return value will be the subscripts that were marked.
在panel.identify等identify不同的方法之一是它如何使用subscripts参数。在一般情况下,当一个人在一个面板标识的点,一个希望,以确定用于生产图的数据框的起源,和内,特别是面板。这个信息是可用的面板功能,但只在某些情况下。确保subscripts可用的方法之一是指定subscripts = TRUE在较高水平,如xyplot调用。如果subscripts没有明确指定的调用panel.identify在,但可在panel.args,那么这些值将被使用。否则,它们默认为seq_along(x)。在这两种情况下,最终的返回值将是显着的标。

The process of printing (plotting) a Trellis object builds up a grid layout with named viewports which can then be accessed to modify the plot further.  While full flexibility can only be obtained by using grid functions directly, a few lattice functions are available for the more common tasks.
印刷过程中(策划)网格对象建立一个名为然后可以访问进一步修改图的视口的网格布局。虽然直接利用网格功能得到充分的灵活性,只能几格功能是较为常见的任务。

trellis.focus can be used to move to a particular panel or strip, identified by its position in the array of panels.  It can also be used to focus on the viewport corresponding to one of the labels or a legend, though such usage would be less useful.  The exact viewport is determined by the name along with the other arguments, not all of which are relevant for all names.  Note that when more than one object is plotted on a page, trellis.focus will always go to the plot that was created last.  For more flexibility, use grid functions directly (see note below).
trellis.focus可以用来移动到一个特定的面板或条状,确定其位置在面板阵列。它也可以被用来集中在视口对应的标签或传说之一,尽管这种用法,用处不大。确切的视口决定的name连同其他参数,而不是所有这一切都是有关的所有名称。请注意,在页面上绘制多个对象时,trellis.focus会一直到最后创建的图。更多的灵活性,直接使用网格功能(见下文附注)。

After a successful call to trellis.focus, the desired viewport (typically panel or strip area) will be made the "current" viewport (plotting area), which can then be enhanced by calls to standard lattice panel functions as well as grid functions.
成功后调用trellis.focus,所需的视口(通常是面板或带区)将“当前”视口(绘图区),然后可以通过调用标准晶格面板功能以及增强网格功能。

It is quite common to have the layout of panels chosen when a "trellis" object is drawn, and not before then.  Information on the layout (specifically, how many rows and columns, and which packet belongs in which position in this layout) is retained for the last "trellis" object plotted, and is available through trellis.currentLayout.
这是很常见的选择面板的布局时"trellis"绘制对象,而不是在此之前。布局上的信息(特别是,有多少行和列,并包在这种布局中的地位属于)保留最后"trellis"对象的绘制,是可以通过trellis.currentLayout。

trellis.unfocus unsets the focus, and makes the top level viewport the current viewport.
trellis.unfocus取消对焦点,使顶层视当前视口中。

trellis.switchFocus is a convenience function to switch from one viewport to another, while preserving the current row and column.  Although the rows and columns only make sense for panels and strips, they would be preserved even when the user switches to some other viewport (where row/column is irrelevant) and then switches back.
trellis.switchFocus是一个方便的功能,同时保留当前row和column一个视口切换到另一个。虽然行和列,不仅使板和钢带的意义,他们将保留甚至当用户切换到其他一些视口(行/列是无关紧要的),然后切换回。

Once a panel or strip is in focus, trellis.panelArgs can be used to retrieve the arguments that were available to the panel function at that position.  In this case, it can be called without
一旦面板或带的重点是,trellis.panelArgs可用于检索的参数,可在该位置的面板功能。在这种情况下,它可以被称为无


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

panel.identify returns an integer vector containing the subscripts of the identified points (see details above).  The equivalent of identify with pos=TRUE is not yet implemented, but can be considered for addition if requested.
panel.identify返回一个整数的向量确定点标(见上述资料)。相当于identifypos=TRUE尚未实施,但如果需要,还可以考虑。

trellis.panelArgs returns a named list of arguments that were available to the panel function for the chosen panel.
trellis.panelArgs返回一个可供选择面板面板功能参数的命名列表。

trellis.vpname and trellis.grobname return character strings.
trellis.vpname和trellis.grobname返回字符串。

trellis.focus has a meaningful return value only if it has been used to focus on a panel interactively, in which case the return value is a list with components col and row giving the column and row positions respectively of the chosen panel, unless the choice was cancelled (by a right click), in which case the return value is NULL.  If click was outside a panel, both col and row are set to 0.
trellis.focus有一个有意义的返回值,只有当它被用来把重点放在交互式面板,在这种情况下返回值是一个列表组件col和row给列和行分别对所选择的面板位置,除非被取消选择(右击),在这种情况下返回值是NULL。如果点击面板外,同时col和row设置为0。


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

The viewports created by lattice are accessible to the user through trellis.focus as described above.  Functions from the grid package can also be used directly.  For example, current.vpTree can be used to inspect the current viewport tree and seekViewport or downViewport can be used to navigate to these viewports.  For such usage, trellis.vpname and trellis.grobname provides a portable way to access the appropriate viewports and grobs by name.
由晶格创建视口是通过trellis.focus如上所述,用户可访问。从格包的功能也可以直接使用。例如,current.vpTree可以用来检查当前视口中的树和seekViewport或downViewport可用于导航到这些视口。对于这种用法,trellis.vpname和trellis.grobname提供了一个可移植的方式来访问相应的视口和名称grobs。


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


Deepayan Sarkar <a href="mailtoeepayan.Sarkar@R-project.org">Deepayan.Sarkar@R-project.org</a>.  Felix
Andrews provided initial implementations of
<code>panel.identify.qqmath</code> and support for focusing on panels
interctively.




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

identify, Lattice, print.trellis, trellis.currentLayout, current.vpTree, viewports
identify,Lattice,print.trellis,trellis.currentLayout,current.vpTree,viewports


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



## Not run: [#无法运行:]
xyplot(1:10 ~ 1:10)
trellis.focus("panel", 1, 1)
panel.identify()

## End(Not run)[#结束(不运行)]

xyplot(Petal.Length ~ Sepal.Length | Species, iris, layout = c(2, 2))
Sys.sleep(1)

trellis.focus("panel", 1, 1)
do.call("panel.lmline", trellis.panelArgs())
Sys.sleep(0.5)
trellis.unfocus()

trellis.focus("panel", 2, 1)
do.call("panel.lmline", trellis.panelArgs())
Sys.sleep(0.5)
trellis.unfocus()

trellis.focus("panel", 1, 2)
do.call("panel.lmline", trellis.panelArgs())
Sys.sleep(0.5)
trellis.unfocus()


## choosing loess smoothing parameter[#选择黄土平滑参数]

p <- xyplot(dist ~ speed, cars)

panel.loessresid <-
    function(x = panel.args$x,
             y = panel.args$y,
             span,
             panel.args = trellis.panelArgs())
{
    fm <- loess(y ~ x, span = span)
    xgrid <- do.breaks(current.panel.limits()$xlim, 50)
    ygrid <- predict(fm, newdata = data.frame(x = xgrid))
    panel.lines(xgrid, ygrid)
    pred <- predict(fm)
    ## center residuals so that they fall inside panel[#中心残差,使他们掉入面板]
    resids <- y - pred + mean(y)
    fm.resid <- loess.smooth(x, resids, span = span)
    ##panel.points(x, resids, col = 1, pch = 4)[#panel.points(X,resids,COL = 1,PCH = 4)]
    panel.lines(fm.resid, col = 1)
}


spans <- c(0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8)
update(p, index.cond = list(rep(1, length(spans))))
panel.locs <- trellis.currentLayout()

i <- 1

for (row in 1:nrow(panel.locs))
    for (column in 1:ncol(panel.locs))
    if (panel.locs[row, column] > 0)
{
    trellis.focus("panel", row = row, column = column,
                  highlight = FALSE)
    panel.loessresid(span = spans[i])
    grid::grid.text(paste("span = ", spans[i]),
                    x = 0.25,
                    y = 0.75,
                    default.units = "npc")
    trellis.unfocus()
    i <- i + 1
}



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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 07:00 , Processed in 0.032066 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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