failed, so I can't see which function is throwing the error. Here's my transcript
> devtools::install_github("Idrissben/ExpoMatch",force=TRUE)
Downloading GitHub repo Idrissben/ExpoMatch@HEAD
✓ checking for file ‘/tmp/RtmpQtG6oG/remotes53beac60dfe2/Idrissben-ExpoMatch-4957199/DESCRIPTION’ ...
─ preparing ‘ExpoMatch’:
✓ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
Omitted ‘LazyData’ from DESCRIPTION
─ building ‘ExpoMatch_0.0.0.9000.tar.gz’
Installing package into ‘/home/roc/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
* installing *source* package ‘ExpoMatch’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
Installing package into ‘/home/roc/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-ExpoMatch/00new’
(as ‘lib’ is unspecified)
Error in contrib.url(repos, type) :
trying to use CRAN without setting a mirror
Error: unable to load R code in package ‘ExpoMatch’
Execution halted
ERROR: lazy loading failed for package ‘ExpoMatch’
* removing ‘/home/roc/R/x86_64-pc-linux-gnu-library/4.1/ExpoMatch’
Warning message:
In i.p(...) :
installation of package ‘/tmp/RtmpQtG6oG/file53bea48598720/ExpoMatch_0.0.0.9000.tar.gz’ had non-zero exit status
This should be avoided: it's up to the user to decide when and how to install packages. What you can do as a developer is add these packages to the Imports: field in the DESCRIPTION file. See here for details.
If I remove these installation lines and install your package, I can call ExpoMatch_function(), the function is found. You didn't copy the error message in your post, so I don't know what function was not found in your tests. Re-running your code, I get this error message:
Error in GenMatch(Tr = Tr, X = X, pop.size = pop.size * 50, max.generations = max.generations * :
could not find function "GenMatch"
This is because the package {GenMatch} was not loaded: you do have a library(GenMatch) call in your R file, but not inside your function. That means it is run when you install the package, but not when you load it!
So there are a few ways to go. You could have a library() call in your function body, that is not a good idea, and not really useful here (note: on my computer, .packages() gives an empty string so won't work, in any case that is not the ideal approach). I would suggest instead using Matching::GenMatch() to specify the package. You can find other approaches here. And same thing for rgenoud::genoud(). Running that on my computer, it seems to work (although as the example took too long to run, I didn't let it finish).
Oh, and if it wasn't clear from my links, I can't recommend enough to read at least the first 2 chapters of the r-pkgs book.