grep - How do I mimic `ls foo*bar` in R? -
completely stumped, though seems simple question voted down shortly duplicate, couldn't find right "pattern" search answer.
i looking files in folder match dual pattern , want open them in r. so, assume list.files
produces following:
lf <- c("foo_23_bar.txt", "goo_42_mar.txt", "boo_42_bar.txt")
in command line, use ls foo*bar
find first file, in r, like,
grep(paste("foo","bar",sep="|"),lf)
returns both files 1 , 3. not sure how use perl=true
option. great. thanks!
i use system function. check out here. http://stat.ethz.ch/r-manual/r-patched/library/base/html/system.html
Comments
Post a Comment