Skip to content

Commit

Permalink
try 7
Browse files Browse the repository at this point in the history
  • Loading branch information
oduerr committed May 18, 2024
1 parent 75d7d3d commit 79c6d4e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"))'
Expand Down
11 changes: 10 additions & 1 deletion R/edudat/R/edudat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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)
}

Expand Down
5 changes: 5 additions & 0 deletions python/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"*.yaml": "home-assistant"
}
}
45 changes: 45 additions & 0 deletions python/main.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 79c6d4e

Please sign in to comment.