Skip to content

pmarcowski/scio

Repository files navigation

scio: AI Summaries of R Objects

Lifecycle: Experimental GitHub release License: GPL-3

scio provides AI-generated summaries of R objects (data frames, plots, text) via the OpenRouter API. Initially conceived to help automate insights from iterative data analysis in notebooks.

Installation

You can install the development version of scio from GitHub with:

# install.packages("devtools")
devtools::install_github("pmarcowski/scio")

Setup

  1. Visit OpenRouter.ai and create an account.
  2. Go to your dashboard and generate an API key.
  3. Set it in R: Sys.setenv(OPENROUTER_API_KEY = "your_key_here").

For persistent use, add OPENROUTER_API_KEY="your_key_here" to your .Renviron file.

Usage

library(scio)

# summarize a data frame
get_summary(head(mtcars))

# summarize a character string
get_summary("This is some text to summarize.")

# summarize a ggplot object
library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
get_summary(p)

You can also embed summaries directly in R Markdown text, like so:

The data shows `r scio::get_summary(my_data)`

Getting Started

For setup and usage example, see the intro vignette.

Configuration

Variable What it controls Default
OPENROUTER_API_KEY (req.) Your API key for authentication —must set
OPENROUTER_MODEL Model to use "openai/gpt-4.1-mini"
OPENROUTER_TOKEN_LIMIT Max tokens for the summary 500
OPENROUTER_SYSTEM_MESSAGE System prompt for role-setting Internal default (see docs)
OPENROUTER_INSTRUCTION User instruction prompt Internal default (see docs)
OPENROUTER_HTTP_REFERER Custom HTTP Referer header "scio"
OPENROUTER_X_TITLE Custom X-Title header "R Summaries via scio"

Feedback

Feature requests and bug reports are welcome. Please open an issue.

License

This project is licensed under GPL-3.0 - see the LICENSE file for details.

Acknowledgements