Created
April 4, 2012 16:48
-
-
Save aespinosa/2303748 to your computer and use it in GitHub Desktop.
Notes: R engineering notation
This file contains 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
# Tip from an email in: http://tolstoy.newcastle.edu.au/R/help/06/07/30469.html | |
formatEng <- function(x) { | |
s<-as.numeric(strsplit(format(x, scientific=T),"e")[[1]]) | |
return(paste(s[1]*10^(s[2]%%3),as.integer(s[2]-(s[2]%%3)),sep="e")) | |
} | |
# Use with sapply on dataframe elements | |
sapply(x$col, formatEng) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment