[R] if exists with regex return

Fred J. phddas at yahoo.com
Thu Mar 25 03:36:39 CET 2004


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




More information about the R-help mailing list