Skip to content

Commit

Permalink
name function properly Pt.3
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrymoudiki committed Jan 12, 2024
1 parent bad4d42 commit 429ea98
Showing 1 changed file with 46 additions and 48 deletions.
94 changes: 46 additions & 48 deletions src/Ahead.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,55 @@ module Ahead

# exports
export dynrmf

if Sys.islinux()
run(`ls -la`)
run(`sudo apt update`)
run(`sudo apt install r-base r-base-dev -y`)
run(`sudo apt-get install libcurl4-openssl-dev`)
run(`sudo apt update`)
run(`sudo apt upgrade`)
run(`Rscript --version`)
username = strip(chomp(read(`whoami`, String)))
run(`sudo chown -R $username:$username /usr/local/lib/R/site-library`) # check permissions
end

__init__ = begin
if Sys.islinux()
run(`ls -la`)
run(`sudo apt update`)
run(`sudo apt install r-base r-base-dev -y`)
run(`sudo apt-get install libcurl4-openssl-dev`)
run(`sudo apt update`)
run(`sudo apt upgrade`)
run(`Rscript --version`)
username = strip(chomp(read(`whoami`, String)))
run(`sudo chown -R $username:$username /usr/local/lib/R/site-library`) # check permissions
# Run the `which R` command to get the path to the R executable
output = strip(chomp(read(`which R`, String)))

# Check if the output is not an empty string (R executable path found)
if output != ""
# Set the obtained R executable path to ENV["R_HOME"]
ENV["R_HOME"] = output
println("R_HOME set to: ", ENV["R_HOME"])
else
println("R executable not found.")
end

using RCall

if Sys.islinux()
username = strip(chomp(read(`whoami`, String)))
run(`sudo usermod -aG staff $username`)
end

if Sys.islinux() || Sys.isapple()
try
run(`sudo Rscript -e "utils::install.packages('foreach', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('Rcpp', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('snow', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('forecast', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('ahead', repos='https://techtonique.r-universe.dev', dependencies=TRUE)"`)
catch e
run(`sudo Rscript -e "install.packages('foreach', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "install.packages('Rcpp', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "install.packages('snow', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "install.packages('forecast', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('ahead', repos='https://techtonique.r-universe.dev', lib= '.', dependencies=TRUE)"`)
end
end

# Run the `which R` command to get the path to the R executable
output = strip(chomp(read(`which R`, String)))

# Check if the output is not an empty string (R executable path found)
if output != ""
# Set the obtained R executable path to ENV["R_HOME"]
ENV["R_HOME"] = output
println("R_HOME set to: ", ENV["R_HOME"])
else
println("R executable not found.")
end

using RCall

if Sys.islinux()
username = strip(chomp(read(`whoami`, String)))
run(`sudo usermod -aG staff $username`)
end

if Sys.islinux() || Sys.isapple()
try
run(`sudo Rscript -e "utils::install.packages('foreach', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('Rcpp', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('snow', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('forecast', repos='https://cran.rstudio.com', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('ahead', repos='https://techtonique.r-universe.dev', dependencies=TRUE)"`)
catch e
run(`sudo Rscript -e "install.packages('foreach', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "install.packages('Rcpp', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "install.packages('snow', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "install.packages('forecast', repos='https://cran.rstudio.com', lib= '.', dependencies=TRUE)"`)
run(`sudo Rscript -e "utils::install.packages('ahead', repos='https://techtonique.r-universe.dev', lib= '.', dependencies=TRUE)"`)
end
end

R"load_ahead <- try(library(ahead), silent = TRUE)"
end
R"load_ahead <- try(library(ahead), silent = TRUE)"

function dynrmf(x)
# https://juliainterop.github.io/RCall.jl/stable/custom/#Nested-conversion
Expand Down

0 comments on commit 429ea98

Please sign in to comment.