Skip to content

Commit

Permalink
Style code and devtools::document()
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Eagles committed Oct 18, 2023
1 parent 12f1504 commit bb657b0
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 15 deletions.
22 changes: 11 additions & 11 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#'
#' @examples
#'
#' array_task = 5 # suppose this is the fifth task in an array job
#' index = 2 # will refer to the 'feature' element of 'loops' below
#' loops = list(
#' array_task <- 5 # suppose this is the fifth task in an array job
#' index <- 2 # will refer to the 'feature' element of 'loops' below
#' loops <- list(
#' region = c("DLPFC", "HIPPO"), feature = c("gene", "exon", "tx", "jxn")
#' )
#' indexing = get_list_indexing(loops, index)
#' this_feature = this_list[[index]][[
#' indexing <- get_list_indexing(loops, index)
#' this_feature <- this_list[[index]][[
#' array_task %/% indexing$divisor %% indexing$modulus
#' ]]
#' sprintf(
Expand Down Expand Up @@ -63,13 +63,13 @@ get_list_indexing <- function(this_list, index) {
#' @examples
#'
#' # Simple example where initials are as expected: 'a', 'b', 'c'
#' fruits = c('apple', 'banana', 'cherry')
#' initials = get_short_flags(fruits)
#' fruits <- c("apple", "banana", "cherry")
#' initials <- get_short_flags(fruits)
#' print(fruits)
#'
#'
#' # Example with duplicates with some arbitrary initials: 'c', 'a', 'b', 'd'
#' fruits = c('coconut', 'cherry', 'banana', 'berry')
#' initials = get_short_flags(fruits)
#' fruits <- c("coconut", "cherry", "banana", "berry")
#' initials <- get_short_flags(fruits)
#' print(fruits)
#'
get_short_flags <- function(vec) {
Expand Down Expand Up @@ -103,7 +103,7 @@ get_short_flags <- function(vec) {
#'
#' @examples
#'
#' fruits = c('apple', 'banana', 'cherry')
#' fruits <- c("apple", "banana", "cherry")
#' message(vector_as_code(fruits))
#'
vector_as_code <- function(vec) {
Expand Down
47 changes: 47 additions & 0 deletions man/get_list_indexing.Rd

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

37 changes: 37 additions & 0 deletions man/get_short_flags.Rd

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

28 changes: 28 additions & 0 deletions man/vector_as_code.Rd

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

8 changes: 4 additions & 4 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ test_that(
test_that(
"get_short_flags",
{
fruits = c('coconut', 'cherry', 'banana', 'berry')
expect_equal(get_short_flags(fruits), c('c', 'a', 'b', 'd'))
fruits <- c("coconut", "cherry", "banana", "berry")
expect_equal(get_short_flags(fruits), c("c", "a", "b", "d"))

# Should fail for length > 26
expect_error(
Expand All @@ -101,8 +101,8 @@ test_that(
test_that(
"vector_as_code",
{
fruits = c('coconut', 'cherry', 'banana', 'berry')
initials = vector_as_code(fruits)
fruits <- c("coconut", "cherry", "banana", "berry")
initials <- vector_as_code(fruits)
expect_equal(
vector_as_code(fruits),
'c("coconut", "cherry", "banana", "berry")'
Expand Down

0 comments on commit bb657b0

Please sign in to comment.