if(interactive()){
d <- density(faithful$eruptions, bw = "sj")
h <- l_hist(x = faithful$eruptions, yshows="density")
l <- l_layer.density(h, d, color="steelblue", linewidth=3)
# or l <- l_layer(h, d, color="steelblue", linewidth=3)
}
Run the code above in your browser using DataLab