From 79c6d4ef8248c153cb2084c6b7efe80b73a0d8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20D=C3=BCrr?= Date: Sat, 18 May 2024 14:43:14 +0200 Subject: [PATCH] try 7 --- .github/workflows/main.yml | 5 ---- R/edudat/R/edudat.R | 11 ++++++++- python/.vscode/settings.json | 5 ++++ python/main.yml | 45 ++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 python/.vscode/settings.json create mode 100644 python/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ee4b62..704c73b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,11 +22,6 @@ jobs: - name: Install R uses: r-lib/actions/setup-r@v2 - - name: Install Python - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - name: Install R packages run: | Rscript -e 'install.packages(c("ggplot2", "knitr", "rmarkdown", "remotes"))' diff --git a/R/edudat/R/edudat.R b/R/edudat/R/edudat.R index 7a03c50..81d6292 100644 --- a/R/edudat/R/edudat.R +++ b/R/edudat/R/edudat.R @@ -67,9 +67,11 @@ cache_file <- function(name, url, verbose = FALSE) { #' #' @param name Name of the dataset (e.g., "challenger.csv") #' @param verbose Logical indicating whether to print messages +#' @param show_code Logical indicating whether to just show code, +#' so that the data can be loaded w/o the package #' @return A data frame containing the dataset #' @export -load_data <- function(name, verbose = FALSE) { +load_data <- function(name, verbose = FALSE, show_code = FALSE) { # Throw an error if the file name does not end with ".csv" if (!grepl(".csv$", name)) { stop("Invalid file format. Currently only CSV Files are supported.") @@ -89,6 +91,13 @@ load_data <- function(name, verbose = FALSE) { name = gsub(".csv", "", name) attr(df, "dataset_name") <- name + # Show the code if requested, by printing the data frame + if (show_code) { + message("# Copy&Paste this code to load the data into R:") + message("data <- read.csv(\"", download_url, "\", stringsAsFactors = FALSE)") + message("# Copy&Paste this code to load the data into Python:") + } + return (df) } diff --git a/python/.vscode/settings.json b/python/.vscode/settings.json new file mode 100644 index 0000000..a04b218 --- /dev/null +++ b/python/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "*.yaml": "home-assistant" + } +} \ No newline at end of file diff --git a/python/main.yml b/python/main.yml new file mode 100644 index 0000000..ad66c69 --- /dev/null +++ b/python/main.yml @@ -0,0 +1,45 @@ +name: Render and Deploy All Quarto Documents + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + render: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Quarto + uses: quarto-dev/quarto-actions/setup@v2 + + - name: Install R + uses: r-lib/actions/setup-r@v2 + + - name: Install R packages + run: | + Rscript -e 'install.packages(c("ggplot2", "knitr", "rmarkdown", "remotes"))' + Rscript -e 'remotes::install_github("tensorchiefs/data", subdir = "R/edudat", dependencies = TRUE, upgrade = "always", verbose = TRUE)' + + - name: Install Python packages + run: | + pip install pandas matplotlib + + - name: Render all Quarto documents + run: | + for qmd in data/*.qmd; do + quarto render "$qmd" --to html + done + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./data + publish_branch: gh-pages