FenTechSolutions / CausalDiscoveryToolbox

Package for causal inference in graphs and in the pairwise settings. Tools for graph structure recovery and dependencies are included.
https://fentechsolutions.github.io/CausalDiscoveryToolbox/html/index.html
MIT License
1.12k stars 197 forks source link

How to install R dependencies on Mac? #84

Open zdhNarsil opened 3 years ago

zdhNarsil commented 3 years ago

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

diviyank commented 3 years ago

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

zdhNarsil commented 3 years ago

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'?

diviyank commented 3 years ago

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