Skip to content

Instantly share code, notes, and snippets.

@N0taN3rd
Created September 22, 2016 23:16
Show Gist options
  • Select an option

  • Save N0taN3rd/e4b1b11fb5dea7a60a4ef660bc064909 to your computer and use it in GitHub Desktop.

Select an option

Save N0taN3rd/e4b1b11fb5dea7a60a4ef660bc064909 to your computer and use it in GitHub Desktop.
un-scinote in r
it <- read.csv('reachNums.csv')
reach <- sort(it[,c('reach')])
f2si2<-function (number, rounding=F, sep=" ")
{
lut <- c(1e-24, 1e-21, 1e-18, 1e-15, 1e-12, 1e-09, 1e-06,
0.001, 1, 1000, 1e+06, 1e+09, 1e+12, 1e+15, 1e+18, 1e+21,
1e+24)
pre <- c("y", "z", "a", "f", "p", "n", "u", "m", "", "k",
"M", "G", "T", "P", "E", "Z", "Y")
ix <- findInterval(number, lut)
if (ix>0 && lut[ix]!=1) {
if (rounding==T) {
sistring <- paste(round(number/lut[ix]), pre[ix], sep=sep)
}
else {
sistring <- paste(number/lut[ix], pre[ix], sep=sep)
}
}
else {
sistring <- as.character(number)
}
return(sistring)
}
spos <- pretty(c(0, max(reach)+1), n=20)
slb <- sapply(spos, FUN=f2si2, rounding=T, sep="")
hist.data <- hist(reach,freq = T,xaxt="n",plot=F)
hist.data$counts = log(hist.data$counts, 2)
plot(hist.data,xaxt="n")
axis(1, at=spos, labels=slb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment