Skip to content
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

Function Documentation ReDo #148

Merged
merged 45 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d3bde36
feat: adding the issue templates
vedhav May 10, 2023
63fc2a5
feat: #94 branch off main and implement PR templates
bms63 May 11, 2023
dd81155
fix: Update test-coverage.yaml to address failing CI
bms63 May 11, 2023
a6ada3b
Merge pull request #116 from atorus-research/fix_test_ci
vedhav May 11, 2023
3db5abc
fix: update the r setup action to fix CI
vedhav May 11, 2023
2c3a47f
fix: update the setup in spellcheck CI as well
vedhav May 11, 2023
04a45c1
Merge pull request #118 from atorus-research/hotfix-update-r-checkout…
bms63 May 11, 2023
e27d2df
Merge branch 'main' into 94_pr_template_off_main
bms63 May 11, 2023
e340e56
Merge branch 'main' into 106-add-bug-and-feature-issue-template
bms63 May 11, 2023
7756a7a
Update .github/ISSUE_TEMPLATE/01_bug_report.yml
vedhav May 11, 2023
9155127
Update .github/ISSUE_TEMPLATE/01_bug_report.yml
vedhav May 11, 2023
39679c8
Update .github/ISSUE_TEMPLATE/02_feature_request.yml
vedhav May 11, 2023
207c592
Update .github/ISSUE_TEMPLATE/02_feature_request.yml
vedhav May 11, 2023
b0874df
Update .github/ISSUE_TEMPLATE/02_feature_request.yml
vedhav May 11, 2023
669e0e6
Merge pull request #114 from atorus-research/106-add-bug-and-feature-…
bms63 May 11, 2023
ebf91e5
Merge branch 'main' into 94_pr_template_off_main
bms63 May 11, 2023
231e959
Merge pull request #115 from atorus-research/94_pr_template_off_main
bms63 May 11, 2023
e41fe46
#7 Update documentation to inheritParams where possible
elimillera Jun 7, 2023
27c495e
Update docs to add messaging
elimillera Jun 9, 2023
cb99624
Merge remote-tracking branch 'origin' into 7-function-documentation
elimillera Jun 14, 2023
acc4b8d
add metadata section
elimillera Jun 14, 2023
3625e5f
Update package options documentation
elimillera Jun 14, 2023
c8e6113
Merge branch 'devel' into 7-function-documentation
elimillera Jun 14, 2023
4dd07c9
Update function docs and passing R cmd check
elimillera Jun 14, 2023
c339d5e
Merge branch '7-function-documentation' of github.com:atorus-research…
elimillera Jun 14, 2023
c676711
Update R/length.R
elimillera Jun 15, 2023
334d2f6
Update R/length.R
elimillera Jun 15, 2023
7a168d6
Update R/type.R
elimillera Jun 15, 2023
0e82d92
Update R/length.R
elimillera Jun 15, 2023
3417232
Update R/label.R
elimillera Jun 15, 2023
7ad340b
Update R/order.R
elimillera Jun 15, 2023
b7aaa9f
Update R/order.R
elimillera Jun 15, 2023
55a3e20
Update R/order.R
elimillera Jun 15, 2023
0014120
Fix metadata numbering
elimillera Jun 15, 2023
af7f6d2
Styling
elimillera Jun 15, 2023
985932a
Merge branch '7-function-documentation' of github.com:atorus-research…
elimillera Jun 15, 2023
d8e563c
Update R/label.R
elimillera Jun 15, 2023
0987a2f
Rework type docs
elimillera Jun 15, 2023
35226d7
Merge branch '7-function-documentation' of github.com:atorus-research…
elimillera Jun 15, 2023
ce91175
Describe metadata type for df_label as dataset metadata
elimillera Jun 15, 2023
5630317
Merge branch 'devel' into 7-function-documentation
elimillera Jun 15, 2023
191c885
Merge branch 'devel' into 7-function-documentation
elimillera Jun 15, 2023
3fca4a5
Push up extra type docs
elimillera Jun 15, 2023
3d7bd42
Update vignettes to remove removed functions
elimillera Jun 15, 2023
09d4474
Merge branch 'devel' into 7-function-documentation
elimillera Jun 15, 2023
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
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/01_bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Bug Report
description: Something is not working correctly or is not working at all!
title: "Bug: <Insert Issue Title Here>"
labels: ["bug", "programming"]
body:
- type: markdown
attributes:
value: |
**Example:** Bug: xportr_format() does not assign SAS format for `DATE9.` metadata
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us what were you expecting to happen before the bug?
placeholder: "A bug happened!"
validations:
required: true
- type: textarea
id: session-info
attributes:
label: Session Information
description: Use `sessionInfo()` in the R console to gather all the details of your environment when the bug happened.
placeholder: "Place the console output here"
validations:
required: false
- type: textarea
id: logs
attributes:
label: Reproducible Example
description: We love code that can reproduce the bug. Check out [reprex](https://reprex.tidyverse.org/articles/reprex-dos-and-donts.html)
placeholder: "Please give us as many details as you can! The faster we can recreate the bug, the faster we can get a fix in the works. Warning, Error Messages and Screenshots are also great."
validations:
required: false
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/02_feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Feature Request
description: Enchancement to xportr functionality
title: "Feature Request: <Insert Issue Title Here>"
labels: ["enhancement", "programming"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request! We love keeping xportr fresh!
- type: textarea
id: feature
attributes:
label: Feature Idea
description: Tell us your idea in as few words as possible
placeholder: "`xportr_validate` should do x, y and z"
validations:
required: true
- type: textarea
id: input
attributes:
label: Relevant Input
description: Can you provide what the inputs should look like?
placeholder: "What should the input look like? REMINDER: No patient level data or company sensitive information should be shared via this open public issue"
validations:
required: false
- type: textarea
id: output
attributes:
label: Relevant Output
description: Can you provide what the final output should look like?
placeholder: "What should the output look like? REMINDER: No patient level data or company sensitive information should be shared via this open public issue"
validations:
required: false
- type: textarea
id: code
attributes:
label: Reproducible Example/Pseudo Code
description: Can you provide a working example or a sketch of how the code should work?
placeholder: "We love example code and it will speed up the process! REMINDER: No patient level data or company sensitive information should be shared via this open public issue"
validations:
required: false
22 changes: 22 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Release Description
<!--- Summarize what is being released. -->

## Milestone
<!--- Link to the milestone for the release. --->
<!--- Make sure all relevant issues are included on the linked pages. --->
Milestone:

# Release Checklist
<!--- Fill out the following Release checklist -->

- [ ] DESCRIPTION File version number has been updated
- [ ] DESCRIPTION file updated with New Developers (if applicable)
- [ ] NEWS.md has been updated and issues numbers linked
- [ ] README.md has been updated (if applicable)
- [ ] Vignettes have been updated (if applicable)
- [ ] Ensure all unit tests are passing
- [ ] Review https://r-pkgs.org/release.html for additional checks and guidance
- [ ] Use `rhub::check_for_cran()` for checking CRAN flavors before submission
- [ ] Use `usethis::use_revdep()` to check for any reverse dependencies
- [ ] GitHub actions on this PR are all passing
- [ ] Draft GitHub release created using automatic template and updated with additional details. Remember to click "release" after PR is merged.
30 changes: 30 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Thank you for your Pull Request!

We have developed a Pull Request template to aid you and our reviewers. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the xportr codebase remains robust and consistent.

### The scope of `{xportr}`

`{xportr}`'s scope is to enable R users to write out submission compliant `xpt` files that can be delivered to a Health Authority or to downstream validation software programs. We see labels, lengths, types, ordering and formats from a dataset specification object (SDTM and ADaM) as being our primary focus. We also see messaging and warnings to users around applying information from the specification file as a primary focus. Please make sure your Pull Request meets this **scope of {xportr}**. If your Pull Request moves beyond this scope, please get in touch with the `{xportr}` team on [slack](https://pharmaverse.slack.com/archives/C030EB2M4GM) or create an issue to discuss.

Please check off each task box as an acknowledgment that you completed the task. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the `devel` branch until you have checked off each task.

### Changes Description

_(descriptions of changes)_

### Task List

- [ ] The spirit of xportr is met in your Pull Request
- [ ] Place Closes #<insert_issue_number> into the beginning of your Pull Request Title (Use Edit button in top-right if you need to update)
- [ ] Summary of changes filled out in the above Changes Description. Can be removed or left blank if changes are minor/self-explanatory.
- [ ] Check that your Pull Request is targeting the `devel` branch, Pull Requests to `main` should use the [Release Pull Request Template](https://github.com/atorus-research/xportr/tree/94_pr_template/.github/PULL_REQUEST_TEMPLATE)
- [ ] Code is formatted according to the [tidyverse style guide](https://style.tidyverse.org/). Use `styler` package and functions to style files accordingly.
- [ ] Updated relevant unit tests or have written new unit tests. See our [Wiki](https://github.com/atorus-research/xportr/wiki/Style-Guide-for-Unit-Tests) for conventions used in this package.
- [ ] Creation/updated relevant roxygen headers and examples. See our [Wiki](https://github.com/atorus-research/xportr/wiki/Style-Guide-for-Roxygen-Headers) for conventions used in this package.
- [ ] Run `devtools::document()` so all `.Rd` files in the `man` folder and the `NAMESPACE` file in the project root are updated appropriately
- [ ] Run `pkgdown::build_site()` and check that all affected examples are displayed correctly and that all new/updated functions occur on the "Reference" page.
- [ ] Update NEWS.md if the changes pertain to a user-facing function (i.e. it has an @export tag) or documentation aimed at users (rather than developers)
- [ ] Address any updates needed for vignettes and/or templates
- [ ] Link the issue Development Panel so that it closes after successful merging.
- [ ] Fix merge conflicts
- [ ] Pat yourself on the back for a job well done! Much love to your accomplishment!
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@v1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fetch-depth: 0

- name: Setup R 📊
uses: r-lib/actions/setup-r@v1
uses: r-lib/actions/setup-r@v2
with:
r-version: 4.1.3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@v1

Expand Down
33 changes: 23 additions & 10 deletions R/df_label.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#' Assign Dataset Label
#'
#' Assigns dataset label from a dataset level metadata to a given data frame.
#' This is stored in the 'label' attribute of the dataframe.
#'
#' @param .df A data frame of CDISC standard.
#' @param metadata A data frame containing dataset level metadata.
#' @param domain A character value to subset the `.df`. If `NULL`(default), uses
#' `.df` value as a subset condition.
#' @param metacore `r lifecycle::badge("deprecated")` Previously used to pass metadata now renamed with `metadata`
#' @inheritParams xportr_length
#'
#' @return Data frame with label attributes.
#' @family metadata functions
#' @seealso [xportr_label()], [xportr_format()] and [xportr_length()]
#'
#' @section Metadata: The argument passed in the 'metadata' argument can either
#' be a metacore object, or a data.frame containing the data listed below. If
#' metacore is used, no changes to options are required.
#'
#' For data.frame 'metadata' arguments two columns must be present:
#'
#' 1) Domain Name - passed as the 'xportr.df_domain_name' option. Default:
#' "dataset". This is the column subset by the 'domain' argument in the
#' function.
#'
#' 2) Label Name - passed as the 'xportr.df_label' option. Default:
#' "format". Character values to update the 'format.sas' attribute of the
#' dataframe This is passed to `haven::write_xpt` to note the label.
#'
#' @export
#'
#' @examples
Expand All @@ -27,12 +37,15 @@
#' )
#'
#' adsl <- xportr_df_label(adsl, metadata)
xportr_df_label <- function(.df, metadata = NULL, domain = NULL, metacore = deprecated()) {
xportr_df_label <- function(.df,
metadata = NULL,
domain = NULL,
averissimo marked this conversation as resolved.
Show resolved Hide resolved
metacore = deprecated()) {
if (!missing(metacore)) {
lifecycle::deprecate_warn(
when = "0.3.0",
what = "xportr_format(metacore = )",
with = "xportr_format(metadata = )"
what = "xportr_df_label(metacore = )",
with = "xportr_df_label(metadata = )"
)
metadata <- metacore
}
Expand Down
34 changes: 23 additions & 11 deletions R/format.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
#' Assign SAS Format
#'
#' Assigns a SAS format from a variable level metadata to a given data frame.
#' Assigns a SAS format from a variable level metadata to a given data frame. If
#' no format is found for a given variable, it is set as an empty character
#' vector. This is stored in the format.sas attribute.
#'
#' @param .df A data frame of CDISC standard.
#' @param metadata A data frame containing variable level metadata.
#' @param domain A character value to subset the `.df`. If `NULL`(default), uses
#' `.df` value as a subset condition.
#' @param verbose The action the function takes when a variable label isn't.
#' found. Options are 'stop', 'warn', 'message', and 'none'
#' @param metacore `r lifecycle::badge("deprecated")` Previously used to pass metadata now renamed with `metadata`
#' @inheritParams xportr_length
#'
#' @return Data frame with `SASformat` attributes for each variable.
#' @family metadata functions
#' @seealso [xportr_label()], [xportr_df_label()] and [xportr_length()]
#'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not that messaging is currently not available for this function??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the lack of 'verbose' argument and no messaging section notes that

#' @section Metadata: The argument passed in the 'metadata' argument can either
#' be a metacore object, or a data.frame containing the data listed below. If
#' metacore is used, no changes to options are required.
#'
#' For data.frame 'metadata' arguments three columns must be present:
#'
#' 1) Domain Name - passed as the 'xportr.domain_name' option. Default:
#' "dataset". This is the column subset by the 'domain' argument in the
#' function.
#'
#' 2) Format Name - passed as the 'xportr.format_name' option.
#' Default: "format". Character values to update the 'format.sas' attribute of
#' the column. This is passed to `haven::write` to note the format.
#'
#' 3) Variable Name - passed as the 'xportr.variable_name' option. Default:
#' "variable". This is used to match columns in '.df' argument and the
#' metadata.
#'
#' @export
#'
#' @examples
Expand All @@ -31,7 +44,6 @@
xportr_format <- function(.df,
metadata = NULL,
domain = NULL,
averissimo marked this conversation as resolved.
Show resolved Hide resolved
verbose = getOption("xportr.length_verbose", "none"),
metacore = deprecated()) {
if (!missing(metacore)) {
lifecycle::deprecate_warn(
Expand Down
50 changes: 38 additions & 12 deletions R/label.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
#' Assign Variable Label
#'
#' Assigns variable label from a variable level metadata to a given data frame.
#' This function will give detect if a label is greater than
#' 40 characters which isn't allowed in XPT v5. If labels aren't present for the
#' variable it will be assigned an empty character value. Labels are stored in
#' the 'label' attribute of the column.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' the 'label' attribute of the column.
#' the 'label' attribute of the dataframe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Column should be correct here. Dataframe labels are assigned with xportr_df_label

#'
#' @inheritParams xportr_length
#'
#' @section Messaging: `label_log()` is the primary messaging tool for
#' `xportr_label()`. If there are any columns present in the '.df' that are not
#' noted in the metadata, they cannot be assigned a label and a message will
#' be generated noting the number or variables that have not been assigned a
#' label.
#'
#' If variables were not found in the metadata and the value passed to the
#' 'verbose' argument is 'stop', 'warn', or 'message', a message will be
#' generated detailing the variables that were missing in metadata.
#'
#' @section Metadata: The argument passed in the 'metadata' argument can either
#' be a metacore object, or a data.frame containing the data listed below. If
#' metacore is used, no changes to options are required.
#'
#' For data.frame 'metadata' arguments three columns must be present:
#'
#' 1) Domain Name - passed as the 'xportr.domain_name' option. Default:
#' "dataset". This is the column subset by the 'domain' argument in the
#' function.
#'
#' 2) Variable Name - passed as the 'xportr.variable_name' option.
#' Default: "variable". This is used to match columns in '.df' argument and
#' the metadata.
#'
#' 3) Variable Label - passed as the 'xportr.label' option.
#' Default: "label". These character values to update the 'label' attribute of
#' the column. This is passed to `haven::write` to note the label.
#'
#' @param .df A data frame of CDISC standard.
#' @param metadata A data frame containing variable level metadata.
#' @param domain A character value to subset the `.df`. If `NULL`(default), uses
#' `.df` value as a subset condition.
#' @param verbose The action the function takes when a variable length isn't
#' Found. Options are 'stop', 'warn', 'message', and 'none'
#' @param metacore `r lifecycle::badge("deprecated")` Previously used to pass metadata now renamed with `metadata`
#'
#' @return Data frame with label attributes for each variable.
#' @family metadata functions
#' @seealso [xportr_df_label()], [xportr_format()] and [xportr_length()]
#'
#' @export
#'
#' @examples
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get an example of greater than 40 label or missing label with verbose = warn

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be too verbose for function documentation and would be a good example in the deep-dive vigentte

Expand All @@ -33,13 +59,13 @@
xportr_label <- function(.df,
metadata = NULL,
domain = NULL,
verbose = getOption("xportr.length_verbose", "none"),
verbose = getOption("xportr.label_verbose", "none"),
metacore = deprecated()) {
if (!missing(metacore)) {
lifecycle::deprecate_warn(
when = "0.3.0",
what = "xportr_format(metacore = )",
with = "xportr_format(metadata = )"
what = "xportr_label(metacore = )",
with = "xportr_label(metadata = )"
)
metadata <- metacore
}
Expand Down
Loading