Description Usage Arguments Details See Also Examples
A radio group allows the user to select one value from a set of items. The items may be displayed horizontally or vertically.
1 2 |
items |
Vector of values to select from |
selected |
The initial selected value (as an index). Radio groups must have a selection |
horizontal |
A logical specifying the layout for gradio |
handler |
Called when selection is changed |
action |
Passed to handler when called. |
container |
Optional container to attach widget to |
... |
Passed to |
toolkit |
Which GUI toolkit to use |
The svalue
method returns the selected value by
name. If the extra argument index=TRUE
is specified,
the index of the selected value is given.
The svalue<-
method can be used to set the selected
value. One can specify the value by name or by index if
index=TRUE
is specified.
The "["
method refers to the vector defining the items.
The "[<-"
method can be used to change the vector
defining the items.
The "length"
method returns the number of items.
The radio group is one of several widgets useful to selecting a value
or values from a set of items. See also gcheckbox
,
gcheckboxgroup
, gcombobox
, and
gtable
Methods for gComponent objects are detailed in gWidgets-methods
.
Event Handlers are detailed in gWidgets-handlers
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## Not run:
flavors <- c("vanilla", "chocolate", "strawberry")
w <- gwindow("Radio example", visible=FALSE)
gp <- ggroup(container=w)
glabel("Favorite flavor:",container=gp, anchor=c(0,1))
rb <- gradio(flavors, container=gp)
addHandlerClicked(rb, handler=function(h,..) {
cat(sprintf("You picked %s\n", svalue(h$obj)))
})
visible(w) <- TRUE
betterFlavors <- c("coffee", "mint chip")
rb[] <- betterFlavors
rb[] <- c(betterFlavors, "chocolate") # some toolkits don't allow change of length
rb[3] <- "mango sorbet" ## can change a label name
## set values
svalue(rb) <- "coffee" ## by name
svalue(rb, index=TRUE) <- 1 ## by index
## get selected values
svalue(rb)
svalue(rb, index=TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.