Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R echoing not properly turned off #35

Open
sfromm-plm opened this issue Feb 21, 2017 · 1 comment
Open

R echoing not properly turned off #35

sfromm-plm opened this issue Feb 21, 2017 · 1 comment

Comments

@sfromm-plm
Copy link

When I use r_package more than once, calls alternate between correctly and fully suppressing echoing from rinruby to allowing some echoing; something is being toggled on/off with each call.

I believe that libraries/default.rb should read

def r_package_installed?(package)
  require 'rinruby'
  r = RinRuby.new(:echo=>false)
  r.eval 'packages = installed.packages()[,1]'
  packages = r.pull 'packages'
  packages.include?(package)
end

See also this comment.

@ajongbloets
Copy link

I found that disabling the echo directly on the eval call also works. Just like how it's implemented in the install and remove methods in providers/package.rb. Also by creating a new RinRuby object, you are creating a new R instance and without closing the old instance (created during require 'rinruby') you are working with two R instances of which only 1 is used.

def r_package_installed?(package)
  require 'rinruby'
  R.eval 'packages = installed.packages()[,1]', false
  packages = R.pull 'packages'
  packages.include?(package)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants