mergen employs artificial intelligence to convert data analysis questions into executable code, explanations, and algorithms. The self-correction feature ensures the generated code is optimized for performance and accuracy. mergen features a user-friendly chat interface, enabling users to interact with the AI agent and extract valuable insights from their data effortlessly.
The package website with full documentation is here.
If you want to use mergen in your Rstudio session via an embedded chatbot, try out our companion package mergenstudio.
The easiest way to install mergen is via install.packages
install.packages("mergen")
To get a bug fix or to use a feature from the development version, you can install the development version of mergen from GitHub.
# install.packages("pak")
pak::pak("BIMSBbioinfo/mergen")
- Make an AI platform account. Choices are openai.com, neets.ai (at the time of writing free with some limits), replicate.com , perplexity.ai etc. In addition, you can locally run an LLM in server mode and you can interact with it via API. One example is GPT4all. Some of these solutions are not tested but should work with mergen.
- Create an OpenAI API key to use with the package
- Create a replicate API key
- Set up the API key in R
To interact with an AI API, you require a valid AI API key. To configure your key so that it is present globally in your environment at all times, you can include it in your .Renviron file. This will ensure that the key is automatically loaded.
For setting up mergen, this variable should be called AI_API_KEY
. For
more information on setting up an agent, we recommend you visit Get
Started .
Caution: If you’re using version control systems like GitHub, include .Renviron in your .gitignore file to prevent exposing your personal API key.
Here is how to open your .Renviron file for modification in your project:
require(usethis)
edit_r_environ(scope="project")
For a persistent loading of your API key, add the following line to your
.Renviron file replacing "your_key"
with your key.
AI_API_KEY="your_key"
NOTE: After setting up your API key in the .Renviron file, either
restart the R session or run readRenviron(".Renviron")
to apply the
changes.
If you however wish to set this variable only for a single session, you can use the following command:
Sys.setenv(AI_API_KEY="your_key")
If you used mergen please cite:
- Jacqueline A Jansen, Artür Manukyan, Nour Al Khoury, Altuna Akalin. (2023) "Leveraging large language models for data analysis automation" bioRxiv, doi: 10.1101/2023.12.11.571140
If you encounter a clear bug, please file an issue with a minimal reproducible example on GitHub. There you can also post further questions.