-3

I am trying to create a vector from a list of file names in my current directory.

Say there are files, "a.txt", "b.txt", "c.txt", "D.txt" in the directory, I want to create a vector V with ("a", "b", "c", "D").

myFiles <- c("a.txt", "b.txt", "c.txt", "D.txt")

How could I achieve this in R?

zx8754
  • 52,746
  • 12
  • 114
  • 209
user3605505
  • 59
  • 1
  • 2
  • 7
  • Please read [this](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and revise your question – Sotos Mar 08 '16 at 13:21
  • @Sotos revise it to what? Seems pretty self explanatory to me. – mtoto Mar 08 '16 at 13:55
  • @mtoto I don't think it matters whether it's clear or not. Once a structure for questions is established from the community then I think all the questions shjould follow that structure regardless how simple they are. IMHO – Sotos Mar 08 '16 at 13:58

1 Answers1

3

We could try

V <- gsub('\\..*', '', list.files())
mtoto
  • 23,919
  • 4
  • 58
  • 71