Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeffrey Goldberg jpgoldberg

View GitHub Profile
@jpgoldberg
jpgoldberg / numbers2words.R
Created Mar 8, 2017 — forked from psychemedia/numbers2words.R
R function to convert numbers to words
View numbers2words.R
#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])