Search code examples
rsavenotation

avoid scientific notation for small numbers


I have this vector:

percentages <- seq(0.000001,0.0001,0.00001)
[1] 1.0e-06 1.1e-05 2.1e-05 3.1e-05 4.1e-05 5.1e-05 6.1e-05 7.1e-05 8.1e-05 9.1e-05

I need to keep them without scientific notation (e-) because I want to use them as part of names for files:

for (i in 1:length(percentages)) {
  write.table(end[[i]],  paste0(mypath,paste("percentage",
                                 percentages[i], "bed",
                                 sep = ".")), 
     row.names= FALSE, col.names=FALSE, quote=FALSE, sep= "\t")
}

I ended up with some files with names like: percentage.1e-05.bed, when I want it in this way: percentage.0.00005.bed

I tried writing:

double(percentages[i])

but it does not work.


Solution

  • We can set this in the options

     options(scipen=999)
     percentages<- seq(0.000001,0.0001,0.00001)
     percentages
     #[1] 0.000001 0.000011 0.000021 0.000031 0.000041 0.000051 0.000061 0.000071 0.000081 0.000091