[R] round() a data frame containing 'character' variables?
Liviu Andronic
landronimirc at gmail.com
Wed Aug 10 11:46:55 CEST 2011
Hello
On Wed, Aug 10, 2011 at 11:41 AM, Dimitris Rizopoulos
<d.rizopoulos at erasmusmc.nl> wrote:
> One approach is the following:
>
> numVars <- sapply(iris, is.numeric)
> iris[numVars] <- lapply(iris[numVars], round, digits = 2)
> head(iris)
>
That's interesting, but still doesn't do what I need. Since it's a
read-only View() operation I would like to avoid at all cost modifying
the original data frame. And since my data frames are relatively big,
I would like to avoid generating unnecessary copies. Basically I would
need round() to ignore objects that it knows it cannot handle.
Any other ideas? Thanks
Liviu
More information about the R-help
mailing list