I would like to add that this is not the case for other languages than R. I know the question is solved and about R, but maybe someone else finds this useful:
Except engine='R' (default), all chunks are executed in separate sessions, so the variables cannot be directly shared. If we want to make use of objects created in previous chunks, we usually have to write them to files (as side effects). For the bash engine, we can use Sys.setenv() to export variables from R to bash (example). Another approach is to use the (experimental) runr package.
Source
Example in R:
x = 4
print(x)
## [1] 4
Python Example 2a):
x=1
print(x)
## 1
Python Example 2b):
print(x)
## Traceback (most recent call last):
## File "<string>", line 1, in <module>
## NameError: name 'x' is not defined
Just FYI.