----------------------- *** Disclaimer *** -----------------------
This e-mail and its contents are subject to the SA Reserve Bank's
Disclaimer and Confidentiality Clause, which can be viewed at:
http://www.reservebank.co.za/disclaimer
Should you be unable to access the link provided, please send a
blank e-mail to Disclaimer@resbank.co.za 
----------------------- *** Disclaimer *** -----------------------


Hi,

Apart from experimenting with gWidgets, I'm also experimenting with RGG. Very impressed with it so far, especially considering it's pre-alpha status. I have, however, found that the accepted-extensions attribute of filechooser doesn't behave as expected. Despite setting accepted-extension=".RData", any file can still be selected.

Here is the basic script I am busy with. It is meant to select the working directory and load the .RData file if that file is selected.

Note that the R script is in a separate file, which the .rgg sourcing that file.

RGG FILE:

<rgg>
 #### First test of RGG. setwd and load .R file
 <filechooser label="Path:" var="path" accepted-extension=".RData"/>
 source("C:/Documents and Settings/p176435/My Documents/gev_application/rgg_test01.R")
 dir = tstDir(path)
 setFun(path, dir = dir)
 if(!dir) load(path)
 getwd()
 ls()
</rgg>

THE R SCRIPT rgg_test01.R:

#### Function to paste togeth characters
pCh <- function(ch){
 x <- ""
 for(i in ch){
  x <- paste(x, i, sep = "")
  }
 return(x)
 }

#### Function to test if file or directory
tstDir <- function(path){
  lch <- unlist(strsplit(path, NULL))
  sq <- seq(length(lch)-5, length(lch))
  lch <- pCh(lch[sq])
  print(lch)
  dir <- ifelse(lch == ".RData", FALSE, TRUE)
  return(dir)
  }

#### Function to set workspace and / or load prev session.
setFun <- function(path, dir = TRUE){
 ifelse(dir, setwd(path), setwd(dirname(path)))
 }

Any help or suggestions whatsoever, would be most appreciated.

Kind regards,




Stefan Janse van Rensburg
Macroprudential Division
Financial Stability Department
SARB
Tel : 012-313 4687
Fax : 012 313 4772

	[[alternative HTML version deleted]]

