[graalvm-users] Integration Ruby x R
rodrigo.a.botafogo at gmail.com
Fri May 11 13:59:17 PDT 2018
Using method_missing, as you did, is exactly the way I've implemented
SciCom (Ruby with Renjin) and plan to work in SciCom2 (Ruby with FastR).
With method_missing we can encapsulate R inside Ruby and there is no need
to use multiple files, for Ruby and R, almost everything can be done in
This is an example of SciCom (plain Ruby with R method calls encapsulate in
the R module):
# This dataset comes from Baseball-Reference.com.
baseball = R.read__csv("baseball.csv")
# Lets look at the data available for Momeyball.
moneyball = R.subset(baseball, baseball.Year < 2002)
# Let's see if we can predict the number of wins, by looking at
# runs allowed (RA) and runs scored (RS). RD is the runs difference.
# We are making a linear model for predicting wins (W) based on RD
moneyball.RD = moneyball.RS - moneyball.RA
wins_reg = R.lm("W ~ RD", data: moneyball)
As another example, here is a SciCom script to print the number of days for
every month is 2005:
everyday = R.seq(from: R.as__Date('2005-1-1'), to:
R.as__Date('2005-12-31'), by: 'day')
cmonth = everyday.format('%b')
.factor(levels: cmonth.unique, ordered: TRUE)
See here that we can chain methods in usual Ruby way. I think this is much
more readable than the R chaining %>% construct.
More information on SciCom - https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_rbotafogo_scicom_wiki&d=DwIFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=CUkXBxBNT_D5N6HMJ5T9Z6rmvNKYsqupcbk72K0lcoQ&m=93M0andXobSZh5VFKbn8JPc7LTMwaih8B1PXYnq3R70&s=JAOYh695J_ZKLiUpp0W21jD54KP15iQR0G9uFHiSsBE&e=
Thanks for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the GraalVM-Users