Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 21st, 2012  |  syntax: None  |  size: 0.30 KB  |  views: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Tip from an email in: http://tolstoy.newcastle.edu.au/R/help/06/07/30469.html
  2.  
  3. formatEng <- function(x) {
  4.    s<-as.numeric(strsplit(format(x, scientific=T),"e")[[1]])
  5.    return(paste(s[1]*10^(s[2]%%3),as.integer(s[2]-(s[2]%%3)),sep="e"))
  6. }
  7.  
  8. # Use with sapply on dataframe elements
  9. sapply(x$col, formatEng)
clone this paste RAW Paste Data