Skip to content
Open
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
1 change: 1 addition & 0 deletions R/REDCap_API.R
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ get_REDCap_log <- function(project,
if(log_begin_date == Sys.Date()){
log_begin_date <- log_begin_date - 1 # keep getting errors for same day checks?
}
# If redcap_log_read() errors, log is set to NULL
log <- tryCatch(
expr = {
REDCapR::redcap_log_read(
Expand Down
8 changes: 4 additions & 4 deletions R/project_to_and_from_dir.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' @title Reads project from the dropped REDCap files in dir/REDCap/upload
#' @inheritParams save_project
#' @param allow_all logical TF for allowing project$data names that are not also
#' @param allow_all logical indicating whether to allow project$data names that are not also
#' form names
#' @param drop_nonredcap_vars logical TF for dropping non-redcap variable names
#' @param drop_non_form_vars logical TF for dropping non-form variable names
#' @param stop_or_warn character string of whether to stop, warn, or do nothing
#' @param drop_nonredcap_vars logical indicating if non-REDCap variable names should be dropped.
#' @param drop_non_form_vars logical indicating if non-form variable names should be dropped.
#' @param stop_or_warn character string indicating whether to stop, warn, or do nothing
#' when forbidden cols are present
#' @return messages for confirmation
#' @export
Expand Down
4 changes: 1 addition & 3 deletions R/setup_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
#' Default is `FALSE`.
#' @param metadata_only Logical (TRUE/FALSE). If TRUE, updates only the
#' metadata. Default is `FALSE`.
#' @param with_data Logical (TRUE/FALSE). If TRUE, loads the test project
#' object with data included.
#' @param get_type optional character of REDCap API call type.
#' data as if user ran `sync_project`. Default is `FALSE`.
#' @param batch_size_download Integer. Number of records to process in each
Expand Down Expand Up @@ -189,7 +187,7 @@ setup_project <- function(
if (!is.null(project_details)) {
add_project_details_to_cache(project_details)
} else {
cli_alert_warning("currupted project_details so will be overwritten")
cli_alert_warning("project_details were corrupted and will be overwritten")
}
# add check for if it was loaded from right place
}
Expand Down
14 changes: 12 additions & 2 deletions R/sync_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@
#' @inheritParams save_project
#' @param set_token_if_fails Logical (TRUE/FALSE). If TRUE, prompts the user to
#' set the REDCap API token if the update fails. Default is `TRUE`.
#' @param reset Logical that forces a fresh update if TRUE. Default is `FALSE`.
#' @param reset Logical. Forces a fresh update if TRUE. Default is `FALSE`.
#' @param ask_about_overwrites Logical (TRUE/FALSE). If TRUE, prompts the user
#' before overwriting existing data. Default is `TRUE`.
#' @param summarize Logical (TRUE/FALSE). If TRUE, summarizes data to directory.
#' @param save_to_dir Logical (TRUE/FALSE). If TRUE, saves the updated data to
#' the directory. Default is `TRUE`.
#' @return Messages for confirmation.
#' @returns Invisibly returns the full path to the new project root.
#' @seealso
#' \link{setup_project} for initializing the `project` object.
#' @family db_functions
#' @examples
#' MyProject <- sync_project(
#' project = MyProject,
#' set_token_if_fails = TRUE,
#' reset = FALSE,
#' silent = FALSE,
#' ask_about_overwrites = TRUE,
#' summarize = TRUE,
#' save_to_dir = TRUE
#' )
#' @export
sync_project <- function(
project,
Expand Down
15 changes: 13 additions & 2 deletions man/sync_project.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vignettes/Basic.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ knitr::opts_chunk$set(
)
```

Here is how to set up a project object. First, load the REDCapSync package.
```{r setup, eval=FALSE}
library(REDCapSync)
```
6 changes: 4 additions & 2 deletions vignettes/project_cache.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ knitr::opts_chunk$set(
)
```

The REDCapSync package benefits from storing/caching key information about your different projects. The two most important pieces of information is the `short_name` and `directory` where it's stored. This is enough information to be able to find where you have chosen to securely store your files, load what has already been collected, and then communicate with R to fetch any new updates. REDCapSync's ability to store your projects in a standardized directory is what allows for powerful pipeline tasks.
The REDCapSync package benefits from storing/caching key information about your different projects. The two most important pieces of information stored in the cache are the `short_name` identifying your project and your `directory` where your project data.frame is stored. Only metadata, no tokens or data files, are stored in the cache. This is enough information to be able to find where you have chosen to securely store your files, load what has already been collected, and then communicate with R to fetch any new updates. REDCapSync's ability to store your projects in a standardized directory is what allows for powerful pipeline tasks.

```{r, eval=F}
library(REDCapSync) # don't forget to load the package
```

# The Cache

Using the `hoadr` package, R finds the standard location where R typically stores cahced package data. For example, on Mac the location might look like, "/Users/yourmacname/Library/Caches/R/REDCapSync". Your exact path can be found with `cache_path()` At the time writing this article, the only thing that REDCapSync stores in this cache is the projects data.frame, which can be loaded with `projects <- get_projects()`.
Using the `hoadr` package, R finds the standard location where R typically stores cached package data. For example, on Mac the location might look like, "/Users/yourmacname/Library/Caches/R/REDCapSync". Your exact path can be found with `cache_path()` At the time writing this article, the only thing that REDCapSync stores in this cache is the projects data.frame, which can be loaded with `projects <- get_projects()`.

```{r, eval=F}
cache_path()
```

# Projects

After a project has been set up, a list object containing cached project data can be retrieved using the get_projects() function. To learn how to set up a project, see the [get started](https://thecodingdocs.github.io/REDCapSync/articles/REDCapSync.html) guide.

```{r, eval=F}
projects <- get_projects()
print.data.frame(projects)
Expand Down