Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffedwards committed Feb 17, 2022
1 parent 575e1b7 commit f84ccbd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
14 changes: 14 additions & 0 deletions util/install.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Setup R Environment
# https://facebookexperimental.github.io/Robyn/docs/quick-start/

install.packages('remotes')
remotes::install_github("facebookexperimental/Robyn/R")

library(Robyn)
library(reticulate)


.libPaths()

Sys.which("R")
echo $PATH
40 changes: 36 additions & 4 deletions util/robyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
########################################################################################################################
# IMPORTS

import os
# os.environ['R_HOME'] = '/usr/local/bin/R'


import rpy2

import rpy2.robjects as robjects
from rpy2.robjects.packages import importr

# import R's "base" package
base = importr('base')

# import R's "utils" package
utils = importr('utils')

Expand All @@ -21,7 +25,6 @@
# RESEARCH
# Remove later - 2022.02.14


# Overview documentation
# https://rpy2.github.io/doc/latest/html/overview.html#
# https://rpy2.github.io/doc/v2.9.x/html/introduction.html
Expand All @@ -36,10 +39,20 @@
# conda activate r-environment
# conda install r-essentials r-base


# conda install -c conda-forge r-essentials r-base
# conda install -c conda-forge rpy2
# r-base-4.1.2


# https://anaconda.org/r/r
# conda install -c r r

# python -m rpy2.situation
# python -m rpy2.tests


# Run .libPaths() in R to find path


# Check location
Expand All @@ -48,6 +61,10 @@
# See ryp2 version
print(f'ryp2 version: {rpy2.__version__}')

# Setup details
import rpy2.situation
for row in rpy2.situation.iter_info():
print(row)

########################################################################################################################
# Step 1: Setup Environment
Expand All @@ -70,9 +87,20 @@
from rpy2.robjects.vectors import StrVector

names_to_install = [x for x in packnames if not rpackages.isinstalled(x)]
print(f'Number of packaged to install: {len(names_to_install)}')
if len(names_to_install) > 0:
utils.install_packages(StrVector(names_to_install))

# robjects.r("version")


# https://thomas-cokelaer.info/blog/2012/01/installing-rpy2-with-different-r-version-already-installed/
# https://stackoverflow.com/questions/64181911/call-r-package-data-using-python-with-rpy2
# https://www.marsja.se/r-from-python-rpy2-tutorial/







Expand Down Expand Up @@ -113,12 +141,13 @@
import os
import pandas as pd

df_prophet_holidays = pd.read_csv(os.path.join(os.getcwd(),'util/data/prophet_holidays.csv'))
df_simulated_weekly = pd.read_csv(os.path.join(os.getcwd(),'util/data/simulated_weekly.csv'))
df_prophet_holidays = pd.read_csv(os.path.join(os.getcwd(), 'util/data/prophet_holidays.csv'))
df_simulated_weekly = pd.read_csv(os.path.join(os.getcwd(), 'util/data/simulated_weekly.csv'))

df_input = df_simulated_weekly
df_holidays = df_prophet_holidays


class InputCollect(object): # rename for python object
def __init__(self,
df_input = pd.DataFrame,
Expand Down Expand Up @@ -169,6 +198,7 @@ def __init__(self,
self.nevergrad_algo = nevergrad_algo,
self.trials = trials


test = InputCollect(df_input=df_input)
test = InputCollect(cores=8)

Expand All @@ -177,6 +207,8 @@ def __init__(self,

test.df_input



########################################################################################################################
# Scratch below
#
Expand Down

0 comments on commit f84ccbd

Please sign in to comment.