Python variables live across chunk boundaries.
x = 1
y = 2
print x
## 1
print y
## 2
Plots generated by matplotlib
are properly displayed.
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.show()
plt.plot([1, 2, 3, 4])
plt.show()
Python can access objects available in the R environment.
x <- 1:5
y <- 6:10
print r.x
## [1, 2, 3, 4, 5]
print r['y']
## [6, 7, 8, 9, 10]
r.hello = "World"
r['answer'] = 42
print(hello)
## [1] "World"
print(answer)
## [1] 42
Arbitrary R code can be evaluated from Python.
mpg = r["mtcars$mpg[1:5]"]
print mpg
## [21.0, 21.0, 22.8, 21.4, 18.7]
y = "a,b,c".split(",")
print y
## ['a', 'b', 'c']
echo
chunk option is respected (for TRUE
and FALSE
values). Output, but not source, should show in the following output.## Chunk with echo = FALSE
results
chunk option is respected for Python outputs. Source, but not output, should show in the following output.print "Chunk with results = 'hide'"
NULL
include
chunk option is respected for Python outputs. No chunk output should appear following this bullet.eval
chunk option is respected for Python outputs.# We have set 'eval = FALSE' here
r["abc"] = 1
exists("abc", envir = globalenv())
## [1] FALSE