Kenneth L. Chiou

Washington University
Deptartment of Anthropology
Campus Box 1114
One Brookings Drive
St. Louis, MO 63130

kenneth.chiou[at]wustl.edu


Home

Welcome to my personal homepage!

I am a Ph.D. student at Washington University focusing on biological anthropology. While my interests are broad, the majority of my projects concentrate on behavior and evolutionary genetics in primates.

NEWS

  • Abstract acceptance notifications have gone out for the 2013 annual meeting of the American Association of Physical Anthropologists. Be sure to stop by the special poster symposium:
    "Recent advances in knowledge of a major papionin taxon: the Kinda baboon"
    As a participant in the symposium, I will be presenting or co-presenting the following posters:
    Chiou, K.L. A pilot description and categorization of Kinda baboon vocalizations.
    Weyher, A.H. and Chiou, K.L. Adult kinda baboon behavior - preliminary results from a two year study.
  • Check out my blog, The Monkey Matters Blog, with latest updates below (via RSS).

Drawing dynamic visualizations

Published May 14, 2013 at 4:02 pm

If you have half an hour to spare, here is a terrific talk by Bret Victor challenging the way scientists think about data visualization and presenting a vision for how best to move forward.



Desman

Published January 8, 2013 at 9:02 am

Desman: Pyrenean (Galemys pyrenaicus) and Russian (Desmana moschata) desmans are aquatic relatives of moles and bizarre, bizarre critters. Just look at them!

ARKive video - Pyrenean desman - overview ARKive video - Russian desman - overview



R number generation

Published January 7, 2013 at 2:46 am

On her blog, Christina Bergey has previously alluded to our discussions about number generation. I am posting my solution here, not because it is the best solution, but because it shows how R code can be written into Unix scripts (see also this previous post).

#!/bin/bash
# Arguments = vector -n digits -p prefix -s suffix

vector=$1;

digits="max(nchar($vector))";
prefix=;
suffix=;

OPTIND=2;
while getopts n:p:s: opt; do
	case $opt in
		n) digits=$OPTARG;;
		p) prefix=$OPTARG;;
		s) suffix=$OPTARG;;
	esac
done

echo "cat(paste('$prefix',formatC($vector,width=$digits,
	format='d',flag='0'),'$suffix',sep=''),sep='\\n')" | 
	/usr/bin/R --quiet --vanilla --slave

exit;

Now suppose you want to utilize the above number generation script to rename image files. Your current directory contains exactly ten .jpg images:

dog.jpg
dog_and_me.jpg
dog_at_beach.jpg
dog_in_house.jpg
dog_in_park.jpg
dog_sleeping.jpg
dog_sleeping_super_cute.jpg
dog_sleeping_super_fuzzy.jpg
dog_sneezing.jpg
dog_yawning.jpg

You can rename the files (or rather generate the Unix code for renaming them) using the paste utility and some process substitution. Example below (assumes that num is the name of the Unix script):

paste -d '\ ' <(num 'rep("mv",10)') <(ls -1 *.jpg) <(num 1:10 -p dog -s .jpg)

This outputs:

mv dog.jpg dog01.jpg
mv dog_and_me.jpg dog02.jpg
mv dog_at_beach.jpg dog03.jpg
mv dog_in_house.jpg dog04.jpg
mv dog_in_park.jpg dog05.jpg
mv dog_sleeping.jpg dog06.jpg
mv dog_sleeping_super_cute.jpg dog07.jpg
mv dog_sleeping_super_fuzzy.jpg dog08.jpg
mv dog_sneezing.jpg dog09.jpg
mv dog_yawning.jpg dog10.jpg

Running these commands in Terminal (from the proper directory) will rename all ten images. Your directory listing is now this:

dog01.jpg
dog02.jpg
dog03.jpg
dog04.jpg
dog05.jpg
dog06.jpg
dog07.jpg
dog08.jpg
dog09.jpg
dog10.jpg

As a commenter pointed out in a previous post, R can run directly from Terminal. An R session, however, runs separately from other processes and the work performed in a session cannot be passed along to other programs without the intermediate step of writing files. Here, I show how R code can be written into Unix scripts without the need to start an R session.



© 2013 Kenneth Chiou. All rights reserved.