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.Mon, 15 Jan 2018 00:27:13 +0100Use R resulthttps://ask.sagemath.org/question/40606/use-r-result/ Hi!
I'm new in Sagemath, but I've some experience using R. For example, if I want to generate 100 random numbers from a Bernoulli distribution, I can use the code:
r.rbinom(n=100,size=1,prob=0.25)
But... Is there any way to use the result for another operation in Sagemath? And results related to a linear regression, a given test or a plot (done with R)? May it be more efficient to use Scipy in a general workflow?
Thanks for your answers!
Sun, 14 Jan 2018 22:42:32 +0100https://ask.sagemath.org/question/40606/use-r-result/Answer by tmonteil for <p>Hi!</p>
<p>I'm new in Sagemath, but I've some experience using R. For example, if I want to generate 100 random numbers from a Bernoulli distribution, I can use the code:</p>
<pre><code>r.rbinom(n=100,size=1,prob=0.25)
</code></pre>
<p>But... Is there any way to use the result for another operation in Sagemath? And results related to a linear regression, a given test or a plot (done with R)? May it be more efficient to use Scipy in a general workflow?</p>
<p>Thanks for your answers!</p>
https://ask.sagemath.org/question/40606/use-r-result/?answer=40607#post-id-40607In this case, you can just call the `sage` method:
sage: a = r.rbinom(n=100,size=1,prob=0.25)
sage: a
[1] 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0
[48] 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1
[95] 0 0 1 0 0 0
sage: L = a.sage()
sage: LMon, 15 Jan 2018 00:27:13 +0100https://ask.sagemath.org/question/40606/use-r-result/?answer=40607#post-id-40607