ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 06 Feb 2014 22:10:37 +0100Is there any way to suppress the extra white space from compiling in R?https://ask.sagemath.org/question/10876/is-there-any-way-to-suppress-the-extra-white-space-from-compiling-in-r/Whenever I compile my R code, I get a lot of extra white space that just clogs my worksheet. Is there any way to suppress this? (Without changing the code to be on the same line using semicolons.) I'm working in Sage Worksheets on the cloud.Wed, 05 Feb 2014 16:37:47 +0100https://ask.sagemath.org/question/10876/is-there-any-way-to-suppress-the-extra-white-space-from-compiling-in-r/Answer by William Stein for <p>Whenever I compile my R code, I get a lot of extra white space that just clogs my worksheet. Is there any way to suppress this? (Without changing the code to be on the same line using semicolons.) I'm working in Sage Worksheets on the cloud.</p>
https://ask.sagemath.org/question/10876/is-there-any-way-to-suppress-the-extra-white-space-from-compiling-in-r/?answer=16016#post-id-16016I've made some changes to slightly reduce whitespace in R mode for SageMathCloud (https://cloud.sagemath.com); restart your project to get this update. However, due to how Sage works they might not be sufficient. If you evaluate the following in a cell (in sage mode, or put %sage at the top), it will eliminate a lot of additional whitespace in %r mode.
def r_eval0(*args, **kwds):
return sage.interfaces.r.R.eval(sage.interfaces.r.r, *args, **kwds).strip().replace('\n\n','')
sage_salvus.r_eval0 = r_eval0
Thu, 06 Feb 2014 18:27:54 +0100https://ask.sagemath.org/question/10876/is-there-any-way-to-suppress-the-extra-white-space-from-compiling-in-r/?answer=16016#post-id-16016Comment by kcrisman for <p>I've made some changes to slightly reduce whitespace in R mode for SageMathCloud (<a href="https://cloud.sagemath.com">https://cloud.sagemath.com</a>); restart your project to get this update. However, due to how Sage works they might not be sufficient. If you evaluate the following in a cell (in sage mode, or put %sage at the top), it will eliminate a lot of additional whitespace in %r mode. </p>
<pre><code>def r_eval0(*args, **kwds):
return sage.interfaces.r.R.eval(sage.interfaces.r.r, *args, **kwds).strip().replace('\n\n','')
sage_salvus.r_eval0 = r_eval0
</code></pre>
https://ask.sagemath.org/question/10876/is-there-any-way-to-suppress-the-extra-white-space-from-compiling-in-r/?comment=16309#post-id-16309Think this is worth adding to Sage? Assuming the `.strip()` wouldn't strip *too* much - R likes to indent info in longer output sometimes...Thu, 06 Feb 2014 22:10:37 +0100https://ask.sagemath.org/question/10876/is-there-any-way-to-suppress-the-extra-white-space-from-compiling-in-r/?comment=16309#post-id-16309