title: Calculating the network of co-occurrent terms in text mining
body: <p>I'm new to R and I'm working on some text analysis for multiple pdf files.
  So far I have managed to plot the wordcloud and the bar chart. However, I also need to make the co-occurrence graph or as called Network analysis or links graph. Can anyone help me with some guidance on how to apply that to my current code and what library should I utilize?
  Here is the code:</p>
  <pre><code>require(pdftools)# reads pdf documents
  require(tm)#text mining analysis
  require(wordcloud)
  require(RColorBrewer)
  
  files&lt;-list.files(pattern = &quot;pdf$&quot;)#create vector of pdf file names (i included the pdf files in the same foldr)
  
  alcohol&lt;-lapply(files, pdf_text) #loads all the files
  
  length(alcohol)# check the number of files
  
  lapply(alcohol, length) #check the length of each file
  
  
  pdfdatabase &lt;- Corpus(URISource(files), readerControl = list(reader = readPDF)) #crearing a pdf database 
  pdfdatabase &lt;- tm_map(pdfdatabase, removeWords, stopwords(&quot;english&quot;)) 
  pdfdatabase &lt;- tm_map(pdfdatabase, removeNumbers) 
  alcohol.tdm &lt;- TermDocumentMatrix(pdfdatabase, control = list(removePunctuation = TRUE,
                                                                stopwords = TRUE,
                                                                tolower = TRUE,
                                                                streaming = FALSE,
                                                                removeNumbers = TRUE,
                                                                bounds = list(global = c(3, Inf))))
  
  
  
  ft &lt;- findFreqTerms(alcohol.tdm, lowfreq = 20, highfreq = Inf)
  
  as.matrix(alcohol.tdm[ft,])
  
  ft.tdm &lt;- as.matrix(alcohol.tdm[ft,])
  sort(apply(ft.tdm, 1, sum), decreasing = TRUE)
  
  
  
  #find frequent terms
  findFreqTerms(alcohol.tdm, lowfreq = 10)
  #Examine frequent terms and their association
  findAssocs(alcohol.tdm, terms = &quot;sensor&quot;, corlimit = 0.5)
  
  
  
  
  #convert term document matrix to data frame
  m &lt;- as.matrix(alcohol.tdm)
  v &lt;- sort(rowSums(m),decreasing = TRUE)
  d &lt;- data.frame(word = names(v), freq=v)
  
  
  #create wrodcloud
  set.seed(1234)
  wordcloud(words = d$word, freq = d$freq, min.freq = 10,
            max.words = 200, random.order = FALSE, rot.per = 0.35,
            colors = brewer.pal(8, &quot;Dark2&quot;))
  
  
  
  #Create Bar chart
  barplot(d[1:11,]$freq, las = 2, names.arg = d[1:11,]$word,
          col = &quot;lightblue&quot;, main = &quot;Most frequent words&quot;,
          ylab = &quot;Word freqencies&quot;)
  
  </code></pre>
  <p>Thanks in advance</p>
  <p><a href="https://i.stack.imgur.com/vScMj.jpg" rel="nofollow noreferrer">a screen shot from the console after running the object ft.tdm</a></p>