0

How do I select files based on file extension (writing in r)? Tried

list.files (pattern = ".lvm$") 

in order to select lvm files- no joy

Greg
  • 3,570
  • 5
  • 18
  • 31
krovinski
  • 1
  • 1
  • And what about that didn't work? I don't know what you mean by "no joy" and how that relates to the output you got vs the output you expected – camille Apr 10 '20 at 00:57

1 Answers1

0

You need to escape the "." (as \\.). An unescaped "." means "every character except a new line" in regex.

There's also fs::dir_ls as

fs::dir_ls(data directory, regexp = "\\.lvm$")
Greg
  • 3,570
  • 5
  • 18
  • 31