Repository navigation
Week 3 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Week 3 #4
Changes from all commits
9611a56
3f455df
6fe9b38
b2d343c
1bbed43
adcd67c
df2121b
73b6e43
d0c58fb
65ca09f
fa7e977
554e2bc
6219abe
cd95959
22e068a
bfc094e
b09702f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| AssumptionPlotter::simulate_logistic() |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: GitHub Unit Testing | ||
| run-name: ${{ github.actor }} is checking her unit tests | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| run-unit-tests: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: AssumptionPlotter | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up R | ||
| uses: r-lib/actions/setup-r@v2 | ||
|
|
||
| - name: Install dependencies | ||
| uses: r-lib/actions/setup-r-dependencies@v2 | ||
| with: | ||
| working-directory: AssumptionPlotter | ||
| extra-packages: any::testthat, any::devtools | ||
|
|
||
| - name: Run unit tests | ||
| run: Rscript -e 'devtools::test()' | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Version: 1.0 | ||
|
|
||
| RestoreWorkspace: Default | ||
| SaveWorkspace: Default | ||
| AlwaysSaveHistory: Default | ||
|
|
||
| EnableCodeIndexing: Yes | ||
| UseSpacesForTab: Yes | ||
| NumSpacesForTab: 2 | ||
| Encoding: UTF-8 | ||
|
|
||
| RnwWeave: Sweave | ||
| LaTeX: pdfLaTeX | ||
|
|
||
| AutoAppendNewline: Yes | ||
| StripTrailingWhitespace: Yes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| ^.*\.Rproj$ | ||
| ^\.Rproj\.user$ | ||
| ^vignettes/\.quarto$ | ||
| ^vignettes/*_files$ | ||
| ^\.github$ | ||
| ^README\.Rmd$ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.html |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
| # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
| on: | ||
| push: | ||
| branches: [main, master] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you specify push: branches: [main, master], the CI checks won't run when you push to subbranches (e.g. week-3). So if you always want the checks to run, just include push:. |
||
| pull_request: | ||
|
|
||
| name: R-CMD-check.yaml | ||
|
|
||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| R-CMD-check: | ||
| runs-on: ${{ matrix.config.os }} | ||
|
|
||
| name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| config: | ||
| - {os: macos-latest, r: 'release'} | ||
| - {os: windows-latest, r: 'release'} | ||
| - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} | ||
| - {os: ubuntu-latest, r: 'release'} | ||
| - {os: ubuntu-latest, r: 'oldrel-1'} | ||
|
|
||
| env: | ||
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
| R_KEEP_PKG_SOURCE: yes | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: r-lib/actions/setup-pandoc@v2 | ||
|
|
||
| - uses: r-lib/actions/setup-r@v2 | ||
| with: | ||
| r-version: ${{ matrix.config.r }} | ||
| http-user-agent: ${{ matrix.config.http-user-agent }} | ||
|
|
||
| - uses: r-lib/actions/setup-r-dependencies@v2 | ||
| with: | ||
| extra-packages: any::rcmdcheck | ||
| needs: check | ||
|
|
||
| - uses: r-lib/actions/check-r-package@v2 | ||
| with: | ||
| upload-snapshots: true | ||
| build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| inst/doc | ||
| **/.quarto/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| Package: AssumptionPlotter | ||
| Type: Package | ||
| Title: What the Package Does | ||
| Title: Assumption Plotter | ||
| Version: 0.1.0 | ||
| Authors@R: c( | ||
| person( | ||
|
|
@@ -17,8 +17,13 @@ License: | |
| Encoding: UTF-8 | ||
| LazyData: true | ||
| RoxygenNote: 7.3.2 | ||
| Suggests: | ||
| testthat (>= 3.0.0) | ||
| Config/testthat/edition: 3 | ||
| Imports: | ||
| ggplot2 | ||
| ggplot2, | ||
| knitr, | ||
| quarto, | ||
| testthat, | ||
| usethis | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that knitr, quarto, testthat, and usethis belong in the Suggests section since they are not necessary to run your functions and app. You only need them for your vignette and unit tests. |
||
| VignetteBuilder: quarto | ||
| Depends: | ||
| R (>= 3.5) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| # Generated by roxygen2: do not edit by hand | ||
|
|
||
| export(data_log_plot) | ||
| export(run_plotter) | ||
| export(simulate_logistic) | ||
| import(ggplot2) | ||
| import(shiny) | ||
| import(testthat) | ||
| import(usethis) |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #' Edit dataset to fit plotting | ||
| #' | ||
| #' @details | ||
| #' This function edits the data files (from openESM). Technically, the openesm::get_data function should read the files. However, because the function fails to connect to zenodo, some datasets have been manually saved in the package. To make the plotting smooth, this function cleans the files further for analysis. Load additional datasets, go to the dedicated zenodo webpage from openESM, copy the link for the dataset, and add the dataset manually in the app. If the format is correct, the analysis should still work. Make sure to NOT pick the raw data. | ||
| #' @param df The data frame. Note that the df should be in wide format. | ||
| #' @param id_col Provide the index for which column the participant ID is in. If there is no participant ID (the data frame is for only one participant), write "none". | ||
| #' @param day_col Index number for the column containing the days. | ||
| #' @param exp_day Expected days of the study. | ||
| #' @param beep_col Index number of the column containing the beeps for the day. | ||
| #' @param exp_beep Expected beeps per day. | ||
| #' @param variables A vector containing the names of all columns to be analysed. Each variable must be within quotation marks. | ||
| #' @import dplyr | ||
| #' @returns Creates a data file in the data folder of the package. | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' read_openESM_data("0022_menghini_ts", "https://zenodo.org/records/17347538/files/0022_menghini_ts.tsv?download=1") | ||
| #' } | ||
|
|
||
| edit_df <- function(df, id_col, day_col, exp_day, beep_col, exp_beep, variables){ | ||
|
|
||
| missing <- data.frame( | ||
| id = c(), | ||
| beeps = numeric(), | ||
| days = numeric() | ||
| ) | ||
|
|
||
| participants <- unique(df[[id_col]]) | ||
|
|
||
| for(i in 1:length(participants)){ | ||
| sub_df <- df[df[[id_col]]==participants[i],] | ||
|
|
||
| expected_pairs <- expand.grid( | ||
| beeps = 1:exp_beep, | ||
| days = 1:exp_day | ||
| ) | ||
|
|
||
| actual_pairs <- data.frame( | ||
| beeps = sub_df[[beep_col]], | ||
| days = sub_df[[day_col]] | ||
| ) | ||
| miss <- anti_join(expected_pairs, actual_pairs, by = c("beeps", "days")) | ||
|
|
||
| add <- data.frame( | ||
| id = rep(participants[i], times=nrow(miss)), | ||
| days = miss$days, | ||
| beeps = miss$beeps | ||
| ) | ||
|
|
||
| missing <- rbind(missing, add) | ||
|
|
||
| } | ||
|
|
||
|
|
||
| new_df <- data.frame( | ||
| ID = df[,id_col], | ||
| time = 1:nrow(df), | ||
| day = df[,day_col], | ||
| beep = df[,beep_col] | ||
| ) | ||
|
|
||
| new_var <- paste0("var_", variables) | ||
|
|
||
| for(i in 1:length(new_var)){ | ||
| new_df[new_var[i]] <- df[[variables[i]]] | ||
| } | ||
|
|
||
| return(missing) | ||
| #return(new_df) | ||
| #print(missing) | ||
|
|
||
| } | ||
|
|
||
| buu <- data.frame(x=1:10, y=letters[1:10]) | ||
| buu[h[1]] <- 36:45 | ||
|
|
||
| buu[[h[1]]] | ||
|
|
||
| mode(lu[,2:3]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #' Launch shiny app | ||
| #' | ||
| #' @import shiny | ||
| #' @details | ||
| #' Finding and launching the main app for the AssumptionPlotter package. | ||
| #' | ||
| #' @export | ||
| #' @examples | ||
| #' run_plotter() | ||
| #' | ||
|
|
||
| run_plotter <- function(){ | ||
| app_dir <- system.file("app", package = "AssumptionPlotter") | ||
| runApp(app_dir) | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| --- | ||
| output: github_document | ||
| --- | ||
|
|
||
| <!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
|
||
| ```{r, include = FALSE} | ||
| knitr::opts_chunk$set( | ||
| collapse = TRUE, | ||
| comment = "#>", | ||
| fig.path = "man/figures/README-", | ||
| out.width = "100%" | ||
| ) | ||
| ``` | ||
|
|
||
| # AssumptionPlotter | ||
|
|
||
| <!-- badges: start --> | ||
| [](https://github.com/Programming-The-Next-Step-2026/Assumption-Plotter/actions/workflows/R-CMD-check.yaml) | ||
| <!-- badges: end --> | ||
|
|
||
| The goal of AssumptionPlotter is to ... | ||
|
|
||
| ## Installation | ||
|
|
||
| You can install the development version of AssumptionPlotter from [GitHub](https://github.com/) with: | ||
|
|
||
| ``` r | ||
| # install.packages("pak") | ||
| pak::pak("Programming-The-Next-Step-2026/Assumption-Plotter") | ||
| ``` | ||
|
|
||
| ## Example | ||
|
|
||
| This is a basic example which shows you how to solve a common problem: | ||
|
|
||
| ```{r example} | ||
| library(AssumptionPlotter) | ||
| ## basic example code | ||
| ``` | ||
|
|
||
| What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so: | ||
|
|
||
| ```{r cars} | ||
| summary(cars) | ||
| ``` | ||
|
|
||
| You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. | ||
|
|
||
| You can also embed plots, for example: | ||
|
|
||
| ```{r pressure, echo = FALSE} | ||
| plot(pressure) | ||
| ``` | ||
|
|
||
| In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason that you have two .github folders including the CI code? :)