Description Usage Arguments Details Examples
These functions provide dialogs for file selection (files or directories) and date selections.
1 2 3 4 5 6 7 8 9 10 11 | gfile(text = "", type = c("open", "save", "selectdir"), initialfilename = NULL,
filter = list("All files" = list(patterns = c("*")), "R files" =
list(patterns = c("*.R","*.Rdata")),
"text files" = list(mime.types = c("text/plain"))
), multi=FALSE, handler = NULL, action = NULL, ..., toolkit = guiToolkit())
gfilebrowse (text = "Select a file...", type = "open", quote = TRUE,
container = NULL, ..., toolkit = guiToolkit())
gcalendar(text = "", format = "%Y-%m-%d", handler=NULL,
action=NULL, container = NULL, ..., toolkit = guiToolkit())
|
text |
Initial text. For thecalendar, an optional date in a form matching |
type |
When selecting a file it can be selected for opening, for saving or you may want to select a directory. |
initialfilename |
Suggested name for file save |
filter |
Filter for files shown during selection. Can be nested list, as in example or a named character vector with the names a description and value a file extension (no dots) of files endings to match. |
multi |
Logical. Allow selection of multiple files? |
quote |
Is result quoted |
format |
Format of date, default is year-month-day |
handler |
Handler for when file is changed. The component
|
action |
Passed to handler |
container |
Optional container to attach widget to |
... |
Passed to |
toolkit |
Which GUI toolkit to use |
The gfile
dialog is modal, meaning no action can take
place until a selection is made. Whereas the
gfilebrowse
dialog consists of a gedit
instance
to hold a filename and a button to click if the dialog is
desired to fill in this filename.
The gcalendar
widget is similar to the
gfilebrowse
widget.
For both gcalendar
and gfilebrowse
any
...
arguments are passed to gedit
. The
coerce.with
argument can be used to here to quote the
values, or coerce them otherwise such as with
as.Date
. Otherwise, the svalue
method returns
a character string containing the value shown in the
gedit
box.
The svalue<-()
method may be used to set the value for
both gcalendar
and gfilebrowse
.
The return value is the filename selected. A NA
value is
returned if no file is selected.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Not run:
## source a file using a handler
sourceFile <- function() gfile("Select a file",type="open", handler =
function(h,...) source(h$file))
## source an R file using fact that dialog is modal
source(gfile(filter=c("R files"="R")))
## apply a generic action to the file
countLines <- function(filename) print(length(readLines(filename)))
chooseFile <- function() gfile("Select a file",type="open",
action="countLines", handler = function(h,...) do.call(h$action,list(h$file)))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.