Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AssumptionPlotter::simulate_logistic()
1 change: 0 additions & 1 deletion .github/workflows/github-actions-demo.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/github-unit-testing.yml
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()'





7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ AssumptionPlotter/.Rproj.user

AssumptionPlotter/.Rhistory
.Rproj.user

AssumptionPlotter/.DS_Store
.DS_Store
.DS_Store

AssumptionPlotter/.github
AssumptionPlotter/.github/workflows
16 changes: 16 additions & 0 deletions Assumption-Plotter.Rproj
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
4 changes: 4 additions & 0 deletions AssumptionPlotter/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
^.*\.Rproj$
^\.Rproj\.user$
^vignettes/\.quarto$
^vignettes/*_files$
^\.github$
^README\.Rmd$
1 change: 1 addition & 0 deletions AssumptionPlotter/.github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
50 changes: 50 additions & 0 deletions AssumptionPlotter/.github/workflows/R-CMD-check.yaml
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

Copy link
Copy Markdown

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? :)

on:
push:
branches: [main, master]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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")'
2 changes: 2 additions & 0 deletions AssumptionPlotter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inst/doc
**/.quarto/
13 changes: 9 additions & 4 deletions AssumptionPlotter/DESCRIPTION
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(
Expand All @@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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)
2 changes: 2 additions & 0 deletions AssumptionPlotter/NAMESPACE
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)
52 changes: 0 additions & 52 deletions AssumptionPlotter/R/app.R

This file was deleted.

78 changes: 78 additions & 0 deletions AssumptionPlotter/R/edit_datasets.R
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])
16 changes: 16 additions & 0 deletions AssumptionPlotter/R/run_app.R
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)
}

56 changes: 56 additions & 0 deletions AssumptionPlotter/README.Rmd
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 -->
[![R-CMD-check](https://github.com/Programming-The-Next-Step-2026/Assumption-Plotter/actions/workflows/R-CMD-check.yaml/badge.svg)](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.
Binary file added AssumptionPlotter/data/menghini_2023.rda
Binary file not shown.
Loading
Loading