Test ipynb for documentation

Notebook with kernel R

Code
suppressMessages(suppressWarnings(library("tidyverse")))

Ploting

Code
set.seed(123)
dat = data.frame(
    x = rnorm(1000),
    y = rnorm(1000),
    z = sample(c("a", "b"), size = 1000, replace = TRUE)
)
Code
gpt = ggplot(dat, aes(x=x, y=y, color=z)) + geom_point() + theme_bw()
Code
options(repr.plot.height=2, repr.plot.width=3)
print(gpt)

Code
options(repr.plot.height=5, repr.plot.width=6)
print(gpt)

Showing table

Helper function

Code
fun_display_table = function(dat){
    dat %>%
        kableExtra::kable("html") %>%
        as.character() %>%
        IRdisplay::display_html()
}

Create a table

Code
dat   = data.frame(x=LETTERS, y=letters)
dat_t = dat %>% t %>% data.frame

Without styling

Code
head(dat)
A data.frame: 6 × 2
x y
<chr> <chr>
1 A a
2 B b
3 C c
4 D d
5 E e
6 F f
Code
head(dat_t)
A data.frame: 2 × 26
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
x A B C D E F G H I J Q R S T U V W X Y Z
y a b c d e f g h i j q r s t u v w x y z

With kable styling

Code
fun_display_table(head(dat))
x y
A a
B b
C c
D d
E e
F f
Code
fun_display_table(head(dat_t))
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26
x A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
y a b c d e f g h i j k l m n o p q r s t u v w x y z