title: R freezes and my computer too
body: <p>I don't know whether my question is an easy one to answer, but let's ask it. I'm using R for corpus linguistics and I want to make concordance with a regular expression, using "exact.matches" (cf. St. Th. Gries). The problem is that when I let R run the script, it freezes a long time and my computer freezes too. So I have to restart everything with the power button of my computer.</p>
  
  <p>What I want to try to analyse is a collection of 100 texts (in txt format). The whole bundle is 17,254,537 tokens big, but I have tried to run the code for 20 files at a time. Same problem: everything freezes. Here comes the code:</p>
  
  <pre><code>rm(list=ls(all=T))
  
  setwd("C:/Users/Christophe/Documents/Doctorat_ULg/Corpora/Dutch/Gutenberg_corpus_NL")
  source("C:/_qclwr/_scripts/_scripts_code-exerciseboxes_chapters_3-5/exact_matches_new.R")
  
  corpus.files.1&lt;-choose.files() # to load the first 58 text files
  corpus.files.2&lt;-choose.files() # to load the 42 other files
  whole.corpus.file&lt;-c(corpus.files.1, corpus.files.2) # to concatenate everything into one vector
  all.matches.verbs&lt;-vector()    
  
  for(i in whole.corpus.files) {
    current.corpus.file&lt;-scan(i, what="char", sep="\n", quiet=T)
    current.matches.verbs&lt;-exact.matches("aan&lt;prep&gt;", current.corpus.file, case.sens=F, pcre=T)
    if(length(current.matches.verbs)==0) { next }
    all.matches.verbs&lt;-append(all.matches.verbs, current.matches.verbs)
  }
  </code></pre>
  
  <p>Is there an easy way to solve this problem? It seems it is a problem of memory. I typed the following, if it can help:</p>
  
  <pre><code>&gt; memory.size()
  [1] 35.02
  &gt; memory.limit()
  [1] 3976
  &gt; gc()
            used (Mb) gc trigger (Mb) max used (Mb)
  Ncells  558406 29.9     818163 43.7   741108 39.6
  Vcells 1039743  8.0    1757946 13.5  1300290 10.0
  </code></pre>
  
  <p>I thank you in advance for your precious help.</p>
  
  <p>Best,</p>
  
  <p>CBechet.</p>