This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SortByLetterColumn <- function(df, column_to_sort_by) { | |
# Sorts a data frame by a column containing letters. E.g., A, B, C, ..., AA, BB,... | |
# | |
# Args: | |
# df: data frame to be sorted | |
# column_to_sort_by: (str) column to sort df by | |
# | |
# Returns: | |
# Data frame sorted by specified column. | |
sorted <- df[order(nchar(df[,column_to_sort_by]), df[,column_to_sort_by]), ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires d3 3.2+ and jQuery 1.8+ | |
// CONTRACT | |
// void -> SVG | |
// | |
// PURPOSE | |
// This API both abstracts and extends d3's svg/xml import methods. The goal is to avoid | |
// callback nesting by wrapping d3's async xml calls in a promise, and | |
// then resolving them internally (see jQuery 1.8+ AJAX specs). All | |
// methods return `this` to allow for method cascading. |