File: knitr-print.md

package info (click to toggle)
r-cran-reticulate 1.41.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,088 kB
  • sloc: cpp: 5,154; python: 620; sh: 13; makefile: 2
file content (85 lines) | stat: -rw-r--r-- 1,227 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    bt <- reticulate::import_builtins()
    bt$print("Hello world")

    ## Hello world

## Print statements should always be captured

In `jupyter_compat = FALSE`: we should only see the output of both
expressions.

    print(1)

    ## 1

    print(2)

    ## 2

In `jupyter_compat = TRUE`: we should only see the output of both
expressions.

    print(1)

    ## 1

    print(2)

    ## 2

## Only outputs of last expressions are captured in jupyter compat

In `jupyter_compat = FALSE`: we should only see the output of both
expressions.

    1 + 0

    ## 1

    1 + 1

    ## 2

`jupyter_compat = TRUE`: we should only see the output of the last
expression.

    1 + 0
    1 + 1

    ## 2

## One can disable outputs by using `;`

In `jupyter_compat = FALSE`: we should only see the print statement
output

    print("hello");

    ## hello

    1 + 0;
    1 + 1;

`jupyter_compat = TRUE`: we should only see the print statement output

    print("hello");

    ## hello

    1 + 0;
    1 + 1;

## `jupyter_compat` works with interleaved expressions

    print('first_stdout')

    ## first_stdout

    'first_expression'
    print('second_stdout')

    ## second_stdout

    'final_expression'

    ## 'final_expression'