CoCalc Shared Filestmp / multiple-sessions.sagewsOpen in CoCalc with one click!
Authors: CoCalc Mathfest, William A. Stein
Views : 12
v = [1,3,49,9,10]
r2 = R()
v_in_r = r2(v)
v_in_r
[1] 1 3 49 9 10
v_in_r.summary()
Min. 1st Qu. Median Mean 3rd Qu. Max. 1.0 3.0 9.0 14.4 10.0 49.0
v_in_r.name()
'sage5'
%r2 summary(sage5)
Min. 1st Qu. Median Mean 3rd Qu. Max. 1.0 3.0 9.0 14.4 10.0 49.0
%r2 plot(sage5)
mathematica(v)
Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1044, in execute exec compile(block+'\n', '', 'single', flags=compile_flags) in namespace, locals File "", line 1, in <module> File "/ext/sage/sage-8.2_1604/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 293, in __call__ raise TypeError(msg) TypeError: unable to start mathematica
v_in_r
[1] 1 3 49 9 10
%r2 boxplot(sage5)
r??
File: /cocalc/lib/python2.7/site-packages/smc_sagews/sage_salvus.py Source: def r(code=None,**kwargs): r""" Run R code in a sage worksheet. INPUT: - ``code`` -- a string containing code Use as a decorator. For example, put this in a cell and evaluate it to see a scatter plot of built-in mtcars dataframe variables `mpg` vs `wt`:: %r with(mtcars,plot(wt,mpg)) .. note:: SMC %r mode uses the jupyter `ir` kernel. """ if r.jupyter_kernel is None: r.jupyter_kernel = jupyter("ir") r.jupyter_kernel('options(repr.plot.res = 240)') r.jupyter_kernel.smc_image_scaling = .5 return r.jupyter_kernel(code,**kwargs)
%r boxplot(c(1,2,3,47))
v
[1, 3, 49, 9, 10]
v = [1,2,8,3,5,7]
r('v <- c(' + str(v)[1:-1] + ')')
%r boxplot(v)