I've tried to run presentation "POLYGLOT DATA ANALYSIS VISUALLY DEMONSTRATED WITH PYTHON AND R" Python notebook, running R code dated 2016 from github repo in Colab
but it says lazyeval package is absent.
When I tried to install it as foloows
%%R
install.packages("lazyeval")
it outputs like
R[write to console]: Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified)
R[write to console]: trying URL 'https://cran.rstudio.com/src/contrib/lazyeval_0.2.2.tar.gz'
R[write to console]: Content type 'application/x-gzip' R[write to console]: length 83482 bytes (81 KB)
R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]: = R[write to console]:
R[write to console]: downloaded 81 KB
R[write to console]:
R[write to console]: R[write to console]: The downloaded source packages are in ‘/tmp/Rtmp6hM38b/downloaded_packages’ R[write to console]: R[write to console]:
but no plots are being displayed, with output like full html page inside output cell like this (copy|pasted cell contents)
<html>
<body>
<!--StartFragment--><span style="color: rgb(33, 33, 33); font-family: Roboto, Noto, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">GGPlot with 9 elements.</span><span style="color: rgb(33, 33, 33); font-family: Roboto, Noto, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"></span>
data | R/rpy2 DataFrame (6161 x 8)Request.IDStatusAction.Type...AddressPlatformSubmitted.By'REQ194189''Closed''Repair P......'Concord ...'''bsmyth''REQ194190''Closed''Repair P...'Sunset R...'''bsmyth''REQ194191''Closed''Repair P...'Blanchar...'''bsmyth''REQ194192''Closed''Repair P...'Rindge A...'''bsmyth'..................'REQ545410''Assigned''Repair P...'''iOS''web-serv...'REQ545521''Assigned''Repair P...'''''web-serv...'REQ545560''Assigned''Repair P...'''Android''web-serv...'REQ545621''Assigned''Repair P...'''''web-serv... | Request.ID | Status | Action.Type | ... | Address | Platform | Submitted.By | 'REQ194189' | 'Closed' | 'Repair P... | ... | 'Concord ... | '' | 'bsmyth' | 'REQ194190' | 'Closed' | 'Repair P... | | 'Sunset R... | '' | 'bsmyth' | 'REQ194191' | 'Closed' | 'Repair P... | | 'Blanchar... | '' | 'bsmyth' | 'REQ194192' | 'Closed' | 'Repair P... | | 'Rindge A... | '' | 'bsmyth' | ... | ... | ... | | ... | ... | ... | 'REQ545410' | 'Assigned' | 'Repair P... | | '' | 'iOS' | 'web-serv... | 'REQ545521' | 'Assigned' | 'Repair P... | | '' | '' | 'web-serv... | 'REQ545560' | 'Assigned' | 'Repair P... | | '' | 'Android' | 'web-serv... | 'REQ545621' | 'Assigned' | 'Repair P... | | '' | '' | 'web-serv...
-- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | --
'REQ194189' | 'Closed' | 'Repair P... | ... | 'Concord ... | '' | 'bsmyth'
'REQ194190' | 'Closed' | 'Repair P... | | 'Sunset R... | '' | 'bsmyth'
'REQ194191' | 'Closed' | 'Repair P... | | 'Blanchar... | '' | 'bsmyth'
'REQ194192' | 'Closed' | 'Repair P... | | 'Rindge A... | '' | 'bsmyth'
... | ... | ... | | ... | ... | ...
'REQ545410' | 'Assigned' | 'Repair P... | | '' | 'iOS' | 'web-serv...
'REQ545521' | 'Assigned' | 'Repair P... | | '' | '' | 'web-serv...
'REQ545560' | 'Assigned' | 'Repair P... | | '' | 'Android' | 'web-serv...
'REQ545621' | 'Assigned' | 'Repair P... | | '' | '' | 'web-serv...
ListVector with 1 elements.[no name][RTYPES.ENVSXP] | [RTYPES.ENVSXP]
[RTYPES.ENVSXP]
add: function clone: function find: function get_scales: function has_scale: function input: function n: function non_position_scales: function scales: list super:
...
compute_layout: function draw_back: function draw_front: function draw_labels: function draw_panels: function finish_data: function init_scales: function map_data: function params: list setup_data: function setup_params: function shrink: TRUE train_scales: function vars: function super:
ListVector with 3 elements.x[RTYPES.STRSXP]y[RTYPES.STRSXP]weight[RTYPES.STRSXP] | [RTYPES.STRSXP] | [RTYPES.STRSXP] | [RTYPES.STRSXP]
[RTYPES.STRSXP]
[RTYPES.STRSXP]
[RTYPES.STRSXP]
<!--EndFragment-->
</body>
</html>
Unfortunately, the presentaion project seems to not been able to add an issue.
There is a post at SO Using R in Python with Rpy2: how to ggplot2? with code
import numpy as np
import pandas as pd
import rpy2.robjects.packages as packages
import rpy2.robjects.lib.ggplot2 as ggplot2
import rpy2.robjects as ro
R = ro.r
datasets = packages.importr('datasets')
mtcars = packages.data(datasets).fetch('mtcars')['mtcars']
gp = ggplot2.ggplot(mtcars)
pp = (gp
+ ggplot2.aes_string(x='wt', y='mpg')
+ ggplot2.geom_point(ggplot2.aes_string(colour='qsec'))
+ ggplot2.scale_colour_gradient(low="yellow", high="red")
+ ggplot2.geom_smooth(method='auto')
+ ggplot2.labs(title="mtcars", x='wt', y='mpg'))
pp.plot()
R("dev.copy(png,'/tmp/out.png')")
But in Colab it just outputs
R[write to console]:
geom_smooth()
using method = 'loess' and formula 'y ~ x'
IntVector with 1 elements. 5
What is the proper way to use R ggplot2 code in Python notebooks in Colab and how the notebook can be fixed?