ankur gadgilwar ankur gadgilwar - 3 months ago 27
R Question

RMarkdown conversion

---
title: "Twitter Data processing"
author: "Ankur"
date: "7 September 2016"
output: pdf_document
---

```{r setup, include=FALSE}
library(knitr)
library(SnowballC)
library(tm)
library(ggplot2)
library(RColorBrewer)
library(wordcloud)
```


"SnowballC" is required for stemming the document in this particualr verion. You may alternatively need "Snowball".

```{r Turning into Corpus, include=TRUE, warning=FALSE}
myCorpus<-tm_map(myCorpus, stemDocument)
writeLines(strwrap(myCorpus[[250]]$content,60))
```


I am having issues while knitting the RMD Document. the code works fine but it is not building the RMD file. I have the "myCorpus" variable in other file, butr it is loaded into an environment. I am having the following error:

Error in tm-map(myCorpus, stemDocument) : object ;myCorpus' not found
calls:<Anonymous> ... withCallingHandlers -> withVisible -> eval-> eval ->tm_map Execution Halted

J_F J_F
Answer

There are 2 ways to load the data "myCorpus" to your .RMD file:

  1. library(knitr) knit('your_file.Rmd')

    This will take your recent environment into account and the error should be gone.

  2. Store your "myCorpus" as "myCorpus.RData" and load it manually in your RMD file

    ```{r load myCorpus, include=FALSE}
     load("myCorpus.RData")
    

    If you do it this way you can use the "knit" button from RStudio.

I hope one of this ways is a good solution for you.