Compiling this little function gets me some strange behaviour
.initDataDir <- function(){
if(file.exists(LOCATION)) {
if(as.logical(file.info(LOCATION)["isdir"]))return
stop(LOCATION, " exists but is not a directory")
}
Z <- dir.create(LOCATION)
if(!Z){
stop(geterrmessage())
## stop("Juggel")
}
return(Z)
}
> .initDataDir <- function(){
+ if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)["isdir"]))return
+ stop(LOCATION, " exists but is not a directory")
+ }
+ Z <- dir.create(LOCATION)
+ if(!Z){
+ stop(geterrmessage())
+ ## stop("Juggel")
+ }
+ return(Z)
+ }> LOCATION
[1] "/xxx"> Q <- .initDataDir()
Error in .initDataDir() :
Error in .initDataDir() : Error in .initDataDir() :
Error in .initDataDir() : Error in .initDataDir() : Juggel
In addition: Warning message:
In dir.create(LOCATION) :
cannot create dir '/xxx', reason 'Permission
denied'>
I commented out the stop("Juggel") line
I made a mistake when I first created the function
stop(geterrormessage())
Which failed of course.
Here are some more attempts....
> .initDataDir <- function(){
+ if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)["isdir"]))return
+ stop(LOCATION, " exists but is not a directory")
+ }
+ Z <- dir.create(LOCATION)
+ if(!Z){
+ stop(geterrmessage())
+ stop("Juggel")
+ }
+ return(Z)
+ }> LOCATION
[1] "/xxx"> Q <- .initDataDir()
Error in .initDataDir() : Error in .initDataDir() : Juggel
In addition: Warning message:
In dir.create(LOCATION) :
cannot create dir '/xxx', reason 'Permission
denied'> .initDataDir <- function(){
+ if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)["isdir"]))return
+ stop(LOCATION, " exists but is not a directory")
+ }
+ Z <- dir.create(LOCATION)
+ if(!Z){
+ stop(geterrormessage())
+ stop("Juggel")
+ }
+ return(Z)
+ }> LOCATION
[1] "/xxx"> Q <- .initDataDir()
Error in stop(geterrormessage()) :
could not find function "geterrormessage"
In addition: Warning message:
In dir.create(LOCATION) :
cannot create dir '/xxx', reason 'Permission
denied'>
I tried killing the R session and restarting and then got this....
> .initDataDir <- function(){
+ if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)["isdir"]))return
+ stop(LOCATION, " exists but is not a directory")
+ }
+ Z <- dir.create(LOCATION)
+ if(!Z){
+ stop(geterrmessage())
+ ##stop("Juggel")
+ }
+ return(Z)
+ }> LOCATION <- "/xxxx"
> Q <- .initDataDir()
Error in .initDataDir() : Error in stop(geterrormessage()) :
could not find function "geterrormessage"
In addition: Warning message:
In dir.create(LOCATION) :
cannot create dir '/xxxx', reason 'Permission
denied'>
This is very strange, but not a show stopper.
.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 2
minor 14.1
year 2011
month 12
day 22
svn rev 57956
language R
version.string R version 2.14.1 (2011-12-22)>
cheers
Worik
[[alternative HTML version deleted]]