jim holtman wrote: > Depending on what you want to do, use 'sprintf': > > >> x <- 1.23456789 >> x >> > [1] 1.234568 > >> as.character(x) >> > [1] "1.23456789" > >> sprintf("%.1f %.3f %.5f", x,x,x) >> > [1] "1.2 1.235 1.23457" > > > ... but remember that sprintf introduces excel bugs into r (i.e., rounding is not done according to the IEC 60559 standard, see ?round):
ns = c(0.05, 0.15) round(ns, 1) # 0.0 0.2 as.numeric(sprintf('%.1f', ns)) # 0.1 0.1 vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.