title: Compiling and analysing a Corpus with R and koRpus
body: <p>I'm a student of literature lost in data sciences. I'm trying to analyse a corpus of 70 .txt-files, which are all in one directory. </p>
  
  <p>My final goal is to get a table containing the filename (or something similar), the sentence and word counts, a Flesch-Kincaid readability score and a MTLD lexical diversity score.</p>
  
  <p>I've found the packages koRpus and tm (and tm.plugin.koRpus) and have tried to understand their documentation, but haven't come far. With the help of the RKward IDE and the koRpus-Plugin I manage to get all of these measure for one file at a time and can copy that data into a table manually, but that is very cumbersome and still a lot of work. </p>
  
  <p>What I've tried so far is this command to create a corpus of my files:</p>
  
  <pre><code>simpleCorpus(dir = "/home/user/files/", lang = "en", tagger = "tokenize",
  encoding = "UTF-8", pattern = NULL, recursive = FALSE, ignore.case = FALSE, mode = "text", source = "Wikipedia", format = "file",
  mc.cores = getOption("mc.cores", 1L))
  </code></pre>
  
  <p>But I always get the error:</p>
  
  <pre><code>Error in data.table(token = tokens, tag = unk.kRp):column or argument 1 is NULL).
  </code></pre>
  
  <p>If someone could help an absolute newbie to R I'd be incredibly grateful! </p>