CausalDiscoveryToolbox icon indicating copy to clipboard operation
CausalDiscoveryToolbox copied to clipboard

How to install R dependencies on Mac?

Open zdhNarsil opened this issue 5 years ago • 3 comments

Describe the bug I have R Studio in my mac and have installed packages in https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/r_requirements.txt. But I still get ImportError: R Package bnlearn is not available. when running GS() in:

import cdt import networkx as nx from cdt.causality.graph import GS from cdt.data import load_dataset data, graph = load_dataset("sachs") obj = GS()

Please mention - cdt package version 0.5.22 - python 3.6.12. - PyTorch package version: no torch. anaconda environment.

zdhNarsil avatar Nov 26 '20 06:11 zdhNarsil

Hello, Maybe your 'Rscript' path is refering to the wrong R installation on your machine ; could you check which executable your Rstudio is using? Best, Diviyan

diviyank avatar Dec 10 '20 12:12 diviyank

Hi @Diviyan-Kalainathan , I run ls -l /Library/Frameworks/R.framework/Versions/ and it shows

total 0 drwxrwxr-x 6 root admin 192 Nov 5 2018 3.5 lrwxr-xr-x 1 root admin 3 Nov 5 2018 Current -> 3.5

What do you mean? How can I change 'rscript path'?

zdhNarsil avatar Dec 17 '20 16:12 zdhNarsil

Hello, sorry for the delay, Sorry, it should have been a bit more explicit in the documentation (it is indeed quite hidden) :

cdt.SETTINGS.rpath allows the user to set a custom path for the Rscript executable. It should be overriden with the full path as a string.

Ex:

cdt.SETTINGS.rpath = '/usr/local/bin/Rscript'

But I don't know which Rscript your Rstudio installation is using, check in the Rstudio parameters, there should be a path to an executable somewhere; and then at the beginning of your cdt python scripts you should modify cdt.SETTINGS.rpath

diviyank avatar Jan 05 '21 17:01 diviyank