Knitr gives different results than RStudio

I am doing initial mining using 'tm' and 'RWeka' using Knitr for reproducibility.

I am trying to get a term-document matrix for a body based on two text files, and the process has different results when I run the code in RStudio and when I embed it in an HTML file: HTML file

... when I try other document outputs PDF and Word outputs: PDF and Word outputs

I agree with RStudio.

And I need HTML output ...

Any idea what could happen?

Here is the code .Rmd

---
title: "test"
author: "me"
output: word_document
---

```{r init, echo=FALSE, warning=FALSE, cache=TRUE, message=FALSE}
library(knitr)
library(tm)
library(SnowballC)
library(RWeka)
setwd("~")
options(mc.cores=1) # some problems with parallel processing
```
```{r 1-gram-test, echo=FALSE, eval=TRUE,cache=TRUE}

doc1 <- c("en un lugar de la mancha de cuyo nombre no quiero acordarme habitaba un hidalgo de los de adarga antigual, rocín flaco y galgo corredor")
doc2 <- c("había una vez un barquito chiquitito, que no sabía, que no sabía, que no sabía navegar... pasaron un dos tres cuatro cinco seis semanas y el barquito navegó.")
docs <- c(doc1, doc2)
es <- Corpus(VectorSource(docs),
         readerControl = list(reader = readPlain,
                              language = "ES-es", load = TRUE))
es
# convert to plain text
es1 <- tm_map(es, PlainTextDocument)

monogramtok <- function(x) {
    RWeka::NGramTokenizer(x, RWeka::Weka_control(min = 1, max = 1))
}

es_tdm1 <- TermDocumentMatrix(es1)

esmono_tdm1 <- TermDocumentMatrix(es1, 
                                 control = list(tokenize = monogramtok, 
                                                wordLengths = c(1, Inf))) #,                               

printf("es_tdm1")
es_tdm1

printf("esmono_tdm1")
esmono_tdm1

`` ``

sessionInfo () R 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Work under: OS X 10.11.4 (El Capitan)

locale: [3] ru_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

included base packages: [3] stats graphics grDevices utils datasets base methods

: [3] R.utils_2.2.0 R.oo_1.20.0 R.methodsS3_1.7.1 dplyr_0.4.3 xtable_1.8-0
[6] pander_0.6.0 RWeka_0.4-24 SnowballC_0.5.1 tm_0.6-2 NLP_0.1-9
[11] knitr_1.12.3

+4
1

, , knitr cache=TRUE ( , , ).

, .

, .

+2

All Articles