[R] list.files() find files beginning with a .
ligges at statistik.tu-dortmund.de
Sun Jul 8 15:35:57 CEST 2012
On 08.07.2012 14:47, syrvn wrote:
> when I use list.files with recursive = TRUE and all.files = TRUE, R returns
> a list of strings/paths.
>>From all those strings I want to keep only the ones starting with a .
> I tried using grep to achieve that. However, the problem is that because of
> the recursive list.files parameter,
> for some files beginning with a . there is a path attached. I think it is
> not as simple as it looks because all files
> end with . something. .xlsx or .txt or .r...
> files <- list.files("~", recursive = TRUE, all.files = TRUE)
> files <- files[grep("^.*$", files)]
> I want grep to return only the following to lines:
You do not need grep, let list.files do all the stuff for you:
list.files("~", recursive = TRUE, all.files = TRUE, pattern="^\\.")
> Any ideas on how to solve that issue?
> View this message in context: http://r.789695.n4.nabble.com/list-files-find-files-beginning-with-a-tp4635773.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help