Wednesday, 18 September 2013

Imaginary units of complex numbers dropped by 'knitr'

Imaginary units of complex numbers dropped by 'knitr'

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

No comments:

Post a Comment