Nicer PNG Graphics

TL;DR If you are getting crappy looking png images from rmarkdown html or word documents, try using type=‘cairo’ or dev=‘CairoPNG’ in your chunk options. PNG Graphics?? So, I write a lot of reports using rmarkdown and knitr, and have been using knitr for quite a while. My job involves doing analyses for collaborators and communicating results. Most of the time, I will generate a pdf report, and I get beautiful graphics, thanks to the eps graphics device.

Finding Modes Using Kernel Density Estimates

TL; DR If you have a unimodal distribution of values, you can use R’s density or Scipy’s gaussian_kde to create density estimates of the data, and then take the maxima of the density estimate to get the mode. See below for actual examples in R and Python. Mode in R First, lets do this in R. Need some values to work with. library(ggplot2) set.seed(1234) n_point <- 1000 data_df <- data.