rp.image | R Documentation |
An image is placed inside a panel. When the image is clicked the action function is called with the x and y coordinates of the clicked position.
rp.image(panel, filename, imagename, action=NA, mousedrag=NA, mouseup=NA, pos=NULL, parentname=deparse(substitute(panel)), ...)
panel |
the panel in which the image should appear. This may be passed as a panelname string or the panel object itself. |
filename |
the name of the file where the image is located. |
imagename |
name assigned to the image, used for disposing of the widget |
action |
the function which is called when the image is clicked. |
mousedrag |
the function which is called when the mouse is dragged. |
mouseup |
the function which is called when the mouse is released. |
pos |
the layout instructions. Please see the |
parentname |
this specifies the widget inside which the image should appear. |
... |
... |
The function action
should take three arguments, the panel and the coordinates x
and y
where the image was clicked. At present only GIF images are supported.
See rp.grid
for details of the grid layout system.
If the argument panel
is the panelname string, the same string is returned. If the panel object is used, the altered panel is assigned to both the calling level and panel's environment level.
The action
function should return the panel. Without this assignment any widgets added or alterations made to panel parameters within the action
function will be lost.
The former arguments parent
and ...
have been discontinued in version 1.1. Note also that the argument id
has been renamed name
to be consistent with the rest of rpanel.
rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.
## Not run: gulls.click <- function(panel, x, y) { print(c(x, y)) panel } panel <- rp.control() image.file <- file.path(system.file(package = "rpanel"), "images", "gulllmks.gif") rp.image(panel, image.file, gulls.image, action = gulls.click) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.