Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Problem with caption in a graph


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: Problem with caption in a graph
Date   Sat, 7 Sep 2013 21:54:38 +0000

Benjamin,

I've seen this problem before in a user-written module and I think the author solved it by converting the number to a string at the same time, something like this:

local r2=string(round(e(r2),0.001),"%5.3f")

I think it might even work to leave out the -round()- because formatting the number in string() should round automatically.  (Sorry, I can't check at the moment).

Regards,
Joe Canner
Johns Hopkins University School of Medicine
 
________________________________________
From: [email protected] [[email protected]] on behalf of Benjamin Villena [[email protected]]
Sent: Saturday, September 07, 2013 5:32 PM
To: [email protected]
Subject: st: Problem with caption in a graph

Dear Statalist,
 I want to place the R-squared of a regression on a graph using a code like this

reg y x
local r2=round(e(r2),0.001)
line y x, caption("R2=`r2'" , size(small) position(2) ring(0))

The problem is that the caption text shows R2=0.87600000000000000000001 despite the fact I'm using round to keep only three decimal digits.

I'd appreciate if you can give me some advice on how to deal with this issue.

Thanks


Benjamín

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index