On Thu, Aug 11, 2011 at 4:58 PM, David Winsemius <dwinsem...@comcast.net> wrote: >>> numVars <- sapply(iris, is.numeric) >>> iris[numVars] <- lapply(iris[numVars], round, digits = 2) >>> head(iris) >>> > Then drop the assignment operation and just print: > > ( lapply(iris[numVars], round, digits = 2) ) > That's a nice catch, thanks. The only problem with this approach is that non-numeric variables are simply discarded, while I would prefer for them to be simply ignored.
> Or set your digits argument to print: > > print( head(iris), digits=1) > > Or did I miss something? > As I explained in today's reply to Martin, print(..., digits = 2) and format(..., digits = 2) both display a "minimal number of _significant_ digits". However, for various reasons, I need to specify the "number of decimal places" as in round(..., digits = 2). Both print() and format() don't provide an obvious way to do that. Regards Liviu ______________________________________________ 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.