Skip to content

Commit 297c74d

Browse files
committed
joining functions in topics
1 parent 68480dc commit 297c74d

8 files changed

Lines changed: 46 additions & 79 deletions

File tree

R/read.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ plate_to_df <- function(d) {
8989
}
9090

9191
#' Read platedata formatted data from a spreadsheet
92+
#'
9293
#' @inherit read_keyvalue
9394
#' @return A data frame in long format
9495
#' @noRd
@@ -97,10 +98,14 @@ read_key_plate <- function(drfile, sheet, range, translate = FALSE, translations
9798
plate_to_df(plate)
9899
}
99100

100-
#' Translate long variable names to short variable names
101-
#' @param v A vector of long variable names
101+
#' Translation between long and short variable names
102+
#'
103+
#' @description
104+
#' Translate between long and short variable names. If a translation is missing the original
105+
#' variable long or short variable name from `v` is returned.
106+
#' @param v A vector of variable names
102107
#' @param translations A named vector with long variable names as names and short variable names as values
103-
#' @return A vector of short variable names
108+
#' @return A vector of long or short variable names
104109
#' @export
105110
long_to_shortnames <- function(v, translations) {
106111
positions <- match(v, translations$long)
@@ -112,9 +117,8 @@ long_to_shortnames <- function(v, translations) {
112117
shortnames
113118
}
114119

115-
#' Reverse translate short variable names to long variable names
116-
#' @inherit long_to_shortnames
117120
#' @return A vector of long variable names
121+
#' @rdname long_to_shortnames
118122
#' @export
119123
short_to_longnames <- function(v, translations) {
120124
positions <- match(v, translations$short)

R/utils.R

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
# function to download information from a url, or if it is already in cache to
2-
# use the cache. Note that cacheEnv is initiated in the file aaa.R
3-
# download <- function(url) {
4-
# if (exists(url, envir = .cacheEnv)) {
5-
# return(get(url, envir = .cacheEnv))
6-
# }
7-
# file <- httr2::request(url) |>
8-
# httr2::req_perform() |>
9-
# httr2::resp_body_string()
10-
# assign(url, file, envir = .cacheEnv)
11-
# file
12-
# }
13-
141
#' Create a table from a list of key-value pairs
152
#' @param kvlist A list of key-value pairs
163
#' @param guide A data guide
@@ -34,25 +21,24 @@ kvlist_to_table <- function(kvlist, guide, reverse.translate = TRUE) {
3421
tbl
3522
}
3623

37-
#' Convert a string with a star to a number
24+
#' @title Using stars to indicate rejected values
3825
#' @param x A character vector
39-
#' @return A numeric vector
4026
#' @description
41-
#' If a template uses the convention of putting a star in front of numbers that
42-
#' should be excluded then this function can be used to convert the variable to
43-
#' a number again.
44-
#'
27+
#' If a template uses the convention of putting a star in front of or behind
28+
#' numbers that should be rejected for further use then the function
29+
#' `star_to_number()` can be used to convert the variable to a number. The
30+
#' function `has_star()` checks whether a string has a star. It can be used to
31+
#' generate a logical vector indicating accepted/rejected values.
32+
#' @return Function `star_to_number()` returns a numeric vector, `has_star()`
33+
#' returns a logical vector.
4534
#' @export
4635
star_to_number <- function(x) {
4736
as.numeric(stringr::str_remove_all(x, "[*x?]"))
4837
}
4938

5039
#' Check if a string has a star
51-
#' @param x A character vector
52-
#' @return A logical vector
53-
#' @description
54-
#' This function checks if a string has a star, x or a question mark.
5540
#' @export
41+
#' @rdname star_to_number
5642
#'
5743
has_star <- function(x) {
5844
stringr::str_detect(x, "[*x?]")

R/wells.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ check_wells <- function(wells, format, returnerror = TRUE) {
4747
wells
4848
}
4949

50-
#' Calculate well number from row and column. Function used in `raw_map` function
51-
#' from package `platetools`.
50+
#' Calculate well number from row and column
51+
#'
52+
#' @description This function can be used in the `raw_map()` function from
53+
#' package `platetools`.
5254
#'
5355
#' @param row A character vector with the row names
5456
#' @param col A numeric vector with the column names

man/has_star.Rd

Lines changed: 0 additions & 17 deletions
This file was deleted.

man/long_to_shortnames.Rd

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/short_to_longnames.Rd

Lines changed: 0 additions & 19 deletions
This file was deleted.

man/star_to_number.Rd

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/well_from_rowcol.Rd

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)