When calling head(...)
in a cell in jupyter notebook, we get a nice table with the data
However if I want to do the same in a function, nothing is shown, so I have to use print(head(...))
but the result is less pretty as you can see
Is there a way to get the same type of output as the first image but in a function ?
Jupyter display functions for IRkernel are provided by the IRdisplay package, which gets installed together with IRkernel (by default). Just use:
IRdisplay::display(CO2)
Or load the library into the namespace first:
library(IRdisplay)
data("CO2")
a <- function() {
display(head(CO2))
}
a()
Which works as intended: