I am currently experiencing some strange problems when processing a simple Markdown script under RStudio. Summary() function gives an incorrect result, and I cannot figure what's happening, because RStudio is not giving any error at all.
If I execute the following RMarkdown script (I have put the file with the data here)
```{r}
load('mydata.rda')
summary(mydata$b)
head(sort(mydata$b))
```
```{r}
sessionInfo()
```
I get the following result
load("mydata.rda")
summary(mydata$b)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0 6000 10000 12000 16000 35000
head(sort(mydata$b))
## [1] -0.01 -0.01 0.00 0.00 0.00 0.00
sessionInfo()
## R version 2.15.1 (2012-06-22)
## Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
##
## locale:
## [1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] knitr_1.0.5
##
## loaded via a namespace (and not attached):
## [1] digest_0.5.2 evaluate_0.4.3 formatR_0.6 plyr_1.7.1
## [5] stringr_0.6.1 tools_2.15.1
As you can see, the result is wrong, because the actual minimum value of the 'b' variable is negative, something the summary() execution seems to ignore. I have tried the same with a Knitr Rnw pdf script and it does exactly the same. However, when I run it through Sweave, the result is ok.
What is the summary function returning when it is called under knitr/RStudio? Is this a side effect of something I am missing or a bug?
Regards, Gus