Posts

How to define aesthetic mappings of ggplot2 within another function

ggplot2 is great for visualization, but sometimes we need to include ggplot2 functions within another function. ggplot() uses aes() to define aesthetic mappings of different variables. The question is: how to define aesthetic mappings when writing functions using ggplot()? In this post I will present several approaches. First of all, let’s load the required packages and some test data. library(ggplot2) library(dplyr) data("mtcars") Using aes_string() There are two standard ways to define aesthetic mappings in ggplot2, aes_string() and aes_(). Writing a function using aes_string() is the same as using aes(), but calling the function requires passing the variable names as strings to the function.
2020-03-28
1 min read

Writing Praat scripts in a modular way

Praat is widely used in phonetic research. Working with Praat involves inevitably the Praat scripting. There are plenty of resources of Praat scripts as well as great tutorials to Praat scripting (see below). Why bother writing Praat scripts oneself? Praat scripts written by others can be helpful, but even an script is available which offer the functionality one needs, it is seldom exactly what one wants. It is normal to do some tailoring to the scripts. Users of Praat may be great phoneticians, but rarely are they professional programmers. When I write my own Praat scripts, I try to explicitly adopt some principles and conventions to facilitate the reusability of code. This post is about these principles and conventions.
2019-12-06
3 min read

用pandoc生成大型中文文档的痛点与解决方案

Pandoc是转换文本格式的利器。在用 Pandoc 转换中文文档和生成大型文档时,例如用中文写作毕业论文等时,会遇到一些很麻烦的问题。我在前面的博客里说过我在用 Markdown 写博士毕业论文,这篇博客就我自己的经验讲一下在用 Pandoc 生成大型中文文档的痛点与解决方案。
2019-11-25
6 min read