Skip to content

Instantly share code, notes, and snippets.

View jpgoldberg's full-sized avatar

Jeffrey Goldberg jpgoldberg

View GitHub Profile
@jpgoldberg
jpgoldberg / numbers2words.R
Created March 8, 2017 22:39 — forked from psychemedia/numbers2words.R
R function to convert numbers to words
#https://github.com/ateucher/useful_code/blob/master/R/numbers2words.r
numbers2words <- function(x){
## Function by John Fox found here:
## http://tolstoy.newcastle.edu.au/R/help/05/04/2715.html
## Tweaks by AJH to add commas and "and"
helper <- function(x){
digits <- rev(strsplit(as.character(x), "")[[1]])
nDigits <- length(digits)
if (nDigits == 1) as.vector(ones[digits])