Skip to content

Instantly share code, notes, and snippets.

@andreasjansson
Created August 14, 2011 15:13
Show Gist options
  • Save andreasjansson/1144967 to your computer and use it in GitHub Desktop.
Save andreasjansson/1144967 to your computer and use it in GitHub Desktop.
function(x) {
k.indices <- grep('k', x)
M.indices <- grep('M', x)
G.indices <- grep('G', x)
nums <- as.numeric(gsub("[kMG]", "", x))
nums[k.indices] <- nums[k.indices] * 1000
nums[M.indices] <- nums[M.indices] * 1000000
nums[G.indices] <- nums[G.indices] * 1000000000
nums
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment