[R] comma as decimal separator in xtable

Jakson A. Aquino jaksonaquino at gmail.com
Wed Sep 16 20:26:25 CEST 2009


On Wed, Sep 16, 2009 at 03:16:12PM -0300, Henrique Dallazuanna wrote:
> Try this:
> 
> sapply(x, format, decimal.mark = ',')

Yes, this works as I need, regarding the replacement of dots with
commas.

Thanks!

> 
> On Wed, Sep 16, 2009 at 2:06 PM, Jakson A. Aquino
> <jaksonaquino at gmail.com> wrote:
> > On Wed, Sep 16, 2009 at 09:14:39AM -0300, Henrique Dallazuanna wrote:
> >> Try this also;
> >>
> >> format(coef(summary(lm.D9)), decimal.mark = ',')
> >>
> >> or using gsub:
> >>
> >>  apply(coef(summary(lm.D9)), 2, gsub, pattern = "\\.", replacement = ",")
> >>
> >> using lm.D9 object from ?lm example.
> >
> > Thanks for your suggestion! The problem with the above approach is
> > that all values get the same formatting. For example,
> >
> > x <- c(1.2, 1.2e10)
> > format(x, format = 'g', decimal.mark = ',')
> > [1] "1,2e+00" "1,2e+10"
> >
> > What I would like to get was:
> > [1] "1,2" "1,2e+10"




More information about the R-help mailing list