[R] Strange compiling behaviour

R. Michael Weylandt michael.weylandt at gmail.com
Thu Nov 1 08:41:50 CET 2012


On Wed, Oct 31, 2012 at 9:14 PM, Worik R <worikr at gmail.com> wrote:
> 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)
> }
>

Hi Worik,

I'm afraid I really can't follow your question. Could you come up with
a commented version of your function and explain what clearly what you
are seeing and what you would expect to see instead?

Some things to note

1) In your post, you are rather free using "geterrmessage" and
"geterrormessage" -- not the same.
2) In the function above there's a return() call in the wild.
3) You don't need to return errors thrown by stop. That happens automatically.
4) It looks like you don't have the appropriate write permissions in
the directory in question.

Michael



More information about the R-help mailing list