I was using the comma() funtion in the scales page and was wondering how to chage a the defaults. comm(1000) gives me 1,000 which is what I usually want but how would I change the output to 1.000. I had thought that I could simply do comm(1000, big.mark = ".") but I am getting Error in format.default(x, ..., big.mark = ",", scientific = FALSE, trim = TRUE) : formal argument "big.mark" matched by multiple actual arguments And since I'm here I might as well ask if there is a way to keep a couple fo decemal points rather than rounding to the first integer. Thanks John Kane Kingston ON Canada sessionInfo() R version 3.0.1 (2013-05-16) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 [4] LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] scales_0.2.3 ____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
John Kane <jrkrideau <at> inbox.com> writes:> I was using the comma() funtion in the scales page and was > wondering how to chage a the defaults. comm(1000) gives me 1,000 > which is what I usually want but how would I change the output to > 1.000.Since the comma() function is just a wrapper for format():> scales::commafunction (x, ...) { format(x, ..., big.mark = ",", scientific = FALSE, trim = TRUE) } Why not just define your own function that does what you want? myComma <- function (x, big.mark=",", ...) { format(x, ..., big.mark = big.mark, scientific = FALSE, trim = TRUE) } myComma(1000,".")> I had thought that I could simply do > comm(1000, big.mark = ".") > but I am getting > Error in format.default(x, ..., big.mark = ",", scientific = FALSE, trim TRUE) : > formal argument "big.mark" matched by multiple actual arguments> And since I'm here I might as well ask if there is a way > to keep a couple fo decemal points rather than rounding to the first integer.Not quite sure what you mean here; see ?format for more details. format(1200,big.mark=".",nsmall=2) might be what you want, but if you're going to use "." for big.mark then you might want: options(OutDec=",") [1] "1.200,00"
Thanks Ben, I did just that after getting Duncan's reply. I should have seen it myself but for some reason thought I could treat it as an option. Myopia at its best. John Kane Kingston ON Canada> -----Original Message----- > From: bbolker at gmail.com > Sent: Sun, 2 Jun 2013 20:57:58 +0000 > To: r-help at stat.math.ethz.ch > Subject: Re: [R] Scale package change comma defaults? > > John Kane <jrkrideau <at> inbox.com> writes: > >> I was using the comma() funtion in the scales page and was >> wondering how to chage a the defaults. comm(1000) gives me 1,000 >> which is what I usually want but how would I change the output to >> 1.000. > > Since the comma() function is just a wrapper for format(): > >> scales::comma > function (x, ...) > { > format(x, ..., big.mark = ",", scientific = FALSE, trim = TRUE) > } > > Why not just define your own function that does what you want? > > myComma <- function (x, big.mark=",", ...) > { > format(x, ..., big.mark = big.mark, scientific = FALSE, trim = TRUE) > } > > myComma(1000,".") > >> I had thought that I could simply do >> comm(1000, big.mark = ".") >> but I am getting >> Error in format.default(x, ..., big.mark = ",", scientific = FALSE, trim >> > TRUE) : >> formal argument "big.mark" matched by multiple actual arguments > >> And since I'm here I might as well ask if there is a way >> to keep a couple fo decemal points rather than rounding to the first >> integer. > > Not quite sure what you mean here; see ?format for more details. > > format(1200,big.mark=".",nsmall=2) > > might be what you want, but if you're going to use "." for big.mark > then you might want: > > options(OutDec=",") > > [1] "1.200,00" > > ______________________________________________ > R-help at 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.____________________________________________________________ Receive Notifications of Incoming Messages Easily monitor multiple email accounts & access them with a click. Visit http://www.inbox.com/notifier and check it out!