Skip to content

Instantly share code, notes, and snippets.

@MatthewRalston
Created March 21, 2016 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewRalston/8df5b56401b912128e31 to your computer and use it in GitHub Desktop.
Save MatthewRalston/8df5b56401b912128e31 to your computer and use it in GitHub Desktop.
Scientific notation (5x10^5)
fancy_scientific <- function(l) {
# turn in to character string in scientific notation
l <- format(l, scientific = TRUE)
# quote the part before the exponent to keep all the digits
l <- gsub("^(.*)e", "'\\1'e", l)
# turn the 'e+' into plotmath format
l <- gsub("e", "%*%10^", l)
# return this as an expression
parse(text=l)
}
@MatthewRalston
Copy link
Author

Thanks to Jack Aidley

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment