Hi, why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius
Why is format(10000, big.mark = "\\,") not 10\,000?
7 messages · Uwe Ligges, Marius Hofert, Duncan Murdoch
Actually I expected format(10000, big.mark = "\\\\,") to work (you need to double excape the backslashes here). But the two characters are reversed due to the code in prettyNum(). Not sure if it is expected, but the user was probably not expected to use more than a single character as the big.mark. You can get it right by reversing as in: format(10000, big.mark = ",\\\\") Uwe Ligges
On 30.12.2010 19:32, Marius Hofert wrote:
Hi, why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius
______________________________________________ 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.
Dear Uwe,
Actually I expected format(10000, big.mark = "\\\\,") to work (you need to double excape the backslashes here).
this I also tried :-)
But the two characters are reversed due to the code in prettyNum(). Not sure if it is expected, but the user was probably not expected to use more than a single character as the big.mark. You can get it right by reversing as in: format(10000, big.mark = ",\\\\")
but then I get "10\\,000" instead of "10\,000". The reason why I want to have "10\,000" is for use in LaTeX. If I produce the format "10\\,000" in a table, then xtable gives me 10$\backslash$,000 for the corresponding cell entry, which is wrong :-(. Do you know a trick for that? Cheers, Marius
Uwe Ligges On 30.12.2010 19:32, Marius Hofert wrote:
Hi, why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius
______________________________________________ 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.
On 30.12.2010 19:53, Marius Hofert wrote:
Dear Uwe,
Actually I expected format(10000, big.mark = "\\\\,") to work (you need to double excape the backslashes here).
this I also tried :-)
But the two characters are reversed due to the code in prettyNum(). Not sure if it is expected, but the user was probably not expected to use more than a single character as the big.mark. You can get it right by reversing as in: format(10000, big.mark = ",\\\\")
but then I get "10\\,000" instead of "10\,000".
No, you get "10\,000" which is represented by R when printed as "10\\,000". If you want it as output export it by write......() or just use cat() as in: cat(format(10000, big.mark = ",\\\\")) Uwe The reason why I want to have "10\,000" is for use in LaTeX. If I produce the format "10\\,000" in a table, then xtable gives me 10$\backslash$,000 for the corresponding cell entry, which is wrong :-(. Do you know a trick for that?
Cheers, Marius
Uwe Ligges On 30.12.2010 19:32, Marius Hofert wrote:
Hi, why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius
______________________________________________ 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.
Ahhh, great! I knew it will be correct if the output is directed to a file, but I wanted it for the console [which is perfectly solved by cat()]. Thanks, Uwe. Cheers, Marius
On 2010-12-30, at 19:55 , Uwe Ligges wrote:
On 30.12.2010 19:53, Marius Hofert wrote:
Dear Uwe,
Actually I expected format(10000, big.mark = "\\\\,") to work (you need to double excape the backslashes here).
this I also tried :-)
But the two characters are reversed due to the code in prettyNum(). Not sure if it is expected, but the user was probably not expected to use more than a single character as the big.mark. You can get it right by reversing as in: format(10000, big.mark = ",\\\\")
but then I get "10\\,000" instead of "10\,000".
No, you get "10\,000" which is represented by R when printed as "10\\,000". If you want it as output export it by write......() or just use cat() as in: cat(format(10000, big.mark = ",\\\\")) Uwe The reason why I want to have "10\,000" is for use in LaTeX. If I produce the format "10\\,000" in a table, then xtable gives me 10$\backslash$,000 for the corresponding cell entry, which is wrong :-(. Do you know a trick for that?
Cheers, Marius
Uwe Ligges On 30.12.2010 19:32, Marius Hofert wrote:
Hi, why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius
______________________________________________ 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.
On 30/12/2010 1:53 PM, Marius Hofert wrote:
Dear Uwe,
Actually I expected format(10000, big.mark = "\\\\,") to work (you need to double excape the backslashes here).
this I also tried :-)
But the two characters are reversed due to the code in prettyNum(). Not sure if it is expected, but the user was probably not expected to use more than a single character as the big.mark. You can get it right by reversing as in: format(10000, big.mark = ",\\\\")
but then I get "10\\,000" instead of "10\,000". The reason why I want to have "10\,000" is for use in LaTeX. If I produce the format "10\\,000" in a table, then xtable gives me 10$\backslash$,000 for the corresponding cell entry, which is wrong :-(. Do you know a trick for that?
I think you are confusing strings with the way they are printed. "\\" is how a single backslash is printed (by print()), which escapes the \. Use cat() to output it without adding the escape. Duncan Murdoch
Cheers, Marius
Uwe Ligges On 30.12.2010 19:32, Marius Hofert wrote:
Hi, why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius
______________________________________________ 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.
______________________________________________ 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.
Hi Uwe. As you suggested in a private mail, the reversed big.mark looks like a bug. I've fixed it for R 2.13.0. Duncan Murdoch
On 30/12/2010 1:55 PM, Uwe Ligges wrote:
On 30.12.2010 19:53, Marius Hofert wrote:
Dear Uwe,
Actually I expected format(10000, big.mark = "\\\\,") to work (you need to double excape the backslashes here).
this I also tried :-)
But the two characters are reversed due to the code in prettyNum(). Not sure if it is expected, but the user was probably not expected to use more than a single character as the big.mark. You can get it right by reversing as in: format(10000, big.mark = ",\\\\")
but then I get "10\\,000" instead of "10\,000".
No, you get "10\,000" which is represented by R when printed as "10\\,000". If you want it as output export it by write......() or just use cat() as in: cat(format(10000, big.mark = ",\\\\")) Uwe The reason why I want to have "10\,000" is for use in LaTeX. If I produce the format "10\\,000" in a table, then xtable gives me 10$\backslash$,000 for the corresponding cell entry, which is wrong :-(. Do you know a trick for that?
Cheers, Marius
Uwe Ligges On 30.12.2010 19:32, Marius Hofert wrote:
Hi, why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius
______________________________________________ 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.
______________________________________________ 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.