title: Finding tf-idf value in R
body: <p>I want to know how can we compute tf-idf value of words in R if my text is stored in vector.Till now I have scrape a news website using rvest Package and extracted the link and from there, articles and saved those article in a vector.</p>
  
  <p>Now, my vector contains article in character format,Help me to find tf-idf value from there.Thanks in advance.Here is the code</p>
  
  <pre><code>library(rvest)
  library(xml2)
  pagetitle &lt;- read_html("http://indianexpress.com/latest-news/")
  pagetitle
  url &lt;- pagetitle%&gt;%html_nodes(".title a")%&gt;%html_attr("href")
  len &lt;- length(url)
  articles &lt;- c()
  cnt &lt;- 1
  for (i in 1:2)
  {
   #url
   h_text=""
   c_text=""
   newpage &lt;- read_html(url[i])
   heading &lt;- newpage%&gt;%html_nodes("h1")%&gt;%html_text()
   content &lt;- newpage%&gt;%html_nodes("p")%&gt;%html_text()
   heading &lt;- sapply(heading,tolower)
   heading &lt;- gsub('[[:punct:] ]+',' ',heading)
   heading &lt;- gsub('[0-9]+','',heading)
   h_text  &lt;- paste(h_text,heading,sep = " ")
   content &lt;- sapply(content,tolower)
   n &lt;- length(content)
   for(i in 1:n)
   {
     content[i] &lt;- gsub('[[:punct:] ]+',' ',content[i])
     content[i] &lt;- gsub('[0-9]+','',content[i])
     c_text &lt;- paste(c_text,content[i],sep = " ")
   }
  #h_text
  articles[cnt] &lt;- c_text
  cnt &lt;- cnt+1
  rm(heading,content,h_text,c_text,n,len)
  }
  articles[1]
  articles[2]
  </code></pre>