I came across a strange issue in 'knitr' with R code containing complex numbers entered directly using the "x + yi" notation. For an illustration see the minimal example: http://goo.gl/Yj77kI
The sample code evaluates correctly, both in R console and as a code chunk when compiled with Sweave, resulting in:
> 1i^2
[1] -1+0i
However, when trying to use 'knitr' on the same document, the imaginary unit seems to get lost and what I get is:
1^2
## [1] 1
Any ideas?
Cheers, Andrzej
Output of SessionInfo()
:
R version 3.0.0 (2013-04-03)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.4.1
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.7 formatR_0.9 highr_0.2.1 stringr_0.6.2 tools_3.0.0