You assigned `f' whatever the result of
sub("(.+/.+?/)(.+)?","\\2",p,perl=TRUE) is.  The only way for `f' not to
exist after that assignment (that I can think of anyway) is if there was an
error raised in the sub() call.  Otherwise `f' will always exist!  You
should simply check what value `f' has.  My guess is that you really want
something like:

  if (f == "") ...

or maybe:

  if (nchar(f) == 0) ...

Andy

> From: Fred J.
> 
> Hello
> I am trying for an hour now,  
> 
> > p <- "c:/data/"
> or 
> > p <- "c:/data/abc.hig"
>       
> d <- sub("(.+/.+?/)(.+)","\\1",p,perl=TRUE)
> f <- sub("(.+/.+?/)(.+)?","\\2",p,perl=TRUE)
> 
> if (exists("f")){ #why this gives TRUE no mater what?
> do this with d and f
> } else {
> do that with d
> }
> 
> 
> thanks
> 
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to