title: Create a Corpus from a List of File Paths in R
body: <p>I have 1030 individual .txt files in a directory which represent all the participants in a research study.</p>
  
  <p>I have successfully created a corpus for use with the tm package in R out of all the files in the directory.</p>
  
  <p>Now I'm trying to create corpi of numerous subsets of these files. For example, one corpus of all the female authors and one of the male authors.</p>
  
  <p>I was hoping to be able to pass the Corpus function subsets of a list of file paths, but this has not worked out.</p>
  
  <p>Any help is appreciated. Here is an example to build from:</p>
  
  <pre><code>pathname &lt;- c("C:/Desktop/Samples")
  
  study.files &lt;- list.files(path = pathname, pattern = NULL, all.files = T, full.names = T, recursive = T, ignore.case = T, include.dirs = T) 
  
  ### This gives me a character vector that is equivalent to:
  
  study.files &lt;- c("C:/Desktop/Samples/author1.txt","C:/Desktop/Samples/author2.txt","C:/Desktop/Samples/author3.txt","C:/Desktop/Samples/author4.txt","C:/Desktop/Samples/author5.txt")
  
  ### I define my subsets with numeric vectors
  
  women &lt;- c(1,3)
  men &lt;- c(2,4,5)
  
  ### This creates new character vectors containing the file paths
  women.files &lt;- study.files[women]
  men.files &lt;- study.files[men]
  
  ### Here are the things I've tried to create a corpus from the subsetted list. None of these work.
  
  women_corpus &lt;- Corpus(women.files)
  women_corpus &lt;- Corpus(DirSource(women.files))
  women_corpus &lt;- Corpus(DirSource(unlist(women.files)))
  </code></pre>
  
  <p>The subsets I need to create are rather elaborate, so I can't easily make new folders containing only the text files of interest for each corpus.</p>