Hi.
If you want to do it completely in R you can create R gui using gWidgets
package.
Here is an example of creating gui for function arguments (thanks to John
Verzani):
library(gWidgets)
options(guiToolkit="tcltk")
##' An editor for an argument
##' depends on calss of object
arg_editor <- function(x, cont, ...) UseMethod("arg_editor")
arg_editor.call <- function(x, cont, ...) arg_editor(eval(x), cont, ...)
arg_editor.name <- function(x, cont, ...) arg_editor(eval(x), cont, ...)
arg_editor.numeric <- function(x, cont, ...) gcombobox(sort(unique(x)),
editable=TRUE, coerce.with=as.numeric, cont=cont)
arg_editor.character <- function(x, cont, ...) gcombobox(sort(unique(x)),
editable=TRUE, coerce.with=as.character, cont=cont)
arg_editor.factor <- function(x, cont, ...) gcombobox(sort(unique(x)),
cont=cont)
arg_editor.logical <- function(x, cont, ...) gcombobox(c(TRUE, FALSE),
selected=2 - as.numeric(x[1]), cont=cont)
## This replaces ggenericwidget
make_gui <- function(FUN, parent) {
args <- formals(FUN)
if(missing(parent)) {
parent <- gwindow("Some GUI", visible=FALSE)
}
g <- ggroup(cont=parent, horizontal=FALSE)
lyt <- glayout(cont=g)
n <- length(args)
f <- function(i, nm, x) {
lyt[i,1] <- nm
lyt[i,2] <- arg_editor(args[[i]], cont=lyt)
}
mapply(f, i=seq_along(args), nm=names(args), x=args)
bg <- ggroup(cont=g)
gbutton("ok", cont=bg, handler=function(h, ...) {
values <- lapply(lyt[,2], svalue)
nms <- sapply(lyt[,1], svalue)
names(values) <- nms
do.call(FUN, values)
dispose(parent)
})
visible(parent) <- TRUE
invisible(lyt)
}
## Try it out
s <- function(x=1:4, y = letters, z=TRUE) {
print(list(x, y, z))
assign("x",x, envir=globalenv())
assign("y",y, envir=globalenv())
assign("z",z, envir=globalenv())
}
make_gui(s)
You can easily adjust this example to your needs.
If you want you can use Excel, Access in order to create front end
application and using commandArgs to supply arguments to an R script when
is invoked.
Examples of calling an R scripts from Excel and Access you can find here:
http://www.slideshare.net/djandrija/excelr
http://www.slideshare.net/djandrija/r-and-access-2007
Also, shiny package can be useful here (http://www.rstudio.com/shiny/),
integration of html, php and R...
Hope this helps.
Andrija
On Tue, Apr 23, 2013 at 9:41 AM, Vahe nr <vner75@gmail.com> wrote:
> Hi all,
>
> I have R script which during its run require an input like this:
> choose between one of the grouping factor available :
> c("Village", "Country")
>
> can I automate this part, in other word to pass for example Village when I
> am running the script.
>
> One more thing the script is the TimeSeriesAnalysis {ndvits}.
>
> Thanks in advance for any help or suggestion.
>
> Regards,
> Vahe
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]