How to run Ruby API script in R

Hi everyone. I’m completely new to Ruby, I typically use R for my projects. I am interested in testing Ruby’s google finance API (GitHub - dblock/google-finance-ruby-client: Google Finance web API ruby client with support for retrieving stock quotes and historical prices.) to pull data, however I’d like to do it from within R. Hoping to find some advice from someone that perhaps has experience in using R and Ruby (together) who would have an idea of how I can integrate the two

Here is a basic script from the documentation that I’m hoping to run in order to create a dataframe within R. Is it the correct procedure to use gem install to download the package, then require to load it into a session? (This just might be my thinking from R, seeing as one would typically use install.packages() and then library() to achieve the same effect.

If anyone can assist on how to implement this in R (either through a shell or from an RMarkdown file, I’d appreciate it!


# Install the API

gem install google-finance-ruby-client

# Load the API

require 'google-finance-ruby-client'

# Create dataframe of Microsoft Stock Price Time Series data
prices = GoogleFinance::History.get('MSFT', start_date: Date.parse('2016-01-03'), end_date: Date.parse('2016-01-10'))

You are familiar with R, we are familiar with Ruby. So we could do the otherwise, from R to Ruby. Since you have spent most time in R, you probably know the system() command R: Invoke a System Command. You can just invoke ruby with your script like this and read the output there.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs