Skip to content

Commit 9bb8845

Browse files
committed
Add search function proposed by @wilsonsj100
1 parent 9ab0517 commit 9bb8845

12 files changed

Lines changed: 267 additions & 3 deletions

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
^codecov\.yml$
55
^LICENSE\.md$
66
^misc$
7+
^data-raw$

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ License: MIT + file LICENSE
1313
Encoding: UTF-8
1414
Roxygen: list(markdown = TRUE)
1515
RoxygenNote: 7.3.3
16-
Depends: R (>= 3.4.0)
16+
Depends:
17+
R (>= 3.5)
1718
Imports:
1819
readr,
1920
fpeek,
@@ -26,3 +27,4 @@ Suggests:
2627
covr,
2728
testthat (>= 3.0.0)
2829
Config/testthat/edition: 3
30+
LazyData: true

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export(read_file_dropbox)
1414
export(read_sapflow_file)
1515
export(read_teros_file)
1616
export(scan_folders)
17+
export(search_Lx_variables)
1718
import(dplyr)
1819
import(fpeek)
1920
importFrom(arrow,read_parquet)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,25 @@ read_L2_variable <- function(variable, path, site = NULL, quiet = FALSE) {
104104
})
105105
bind_rows(x)
106106
}
107+
108+
#' Search the list of COMPASS-FME sensor variables
109+
#'
110+
#' @param term Search term, case insensitive (character)
111+
#'
112+
#' @returns Variables whose descriptions match the search term.
113+
#' @export
114+
#' @note The search is case-sensitive but definitely not 'smart';
115+
#' use single words only!
116+
#' @examples
117+
#' search_Lx_variables("redox")
118+
#' search_Lx_variables("this will not find any matches")
119+
search_Lx_variables <- function(term) {
120+
hits <- grep(tolower(term),
121+
tolower(compasstools::Lx_variables$description),
122+
fixed = TRUE)
123+
if(length(hits) > 0) {
124+
compasstools::Lx_variables[hits,]
125+
} else {
126+
message("No matches found")
127+
}
128+
}

R/data.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#' COMPASS-FME sensor data variables
2+
#'
3+
#' A listing of the data variables (the "research names")
4+
#' output by the COMPASS-FME sensor data processing pipeline.
5+
#'
6+
#' @format ## `Lx_variables`
7+
#' A data frame with 154 rows and 2 columns:
8+
#' \describe{
9+
#' \item{research_name}{Name of the output variable}
10+
#' \item{final_units}{Units}
11+
#' \item{description}{Description}
12+
#' }
13+
#' @source See https://github.com/COMPASS-DOE/sensor-data-pipeline
14+
#' @references Pennington et al. (2025), "A Performant, Scalable Processing
15+
#' Pipeline for High-Quality and FAIR Environmental Sensor
16+
#' Data". https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2025JG008807
17+
"Lx_variables"

data-raw/Lx_variables.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## code to prepare `Lx_variables` dataset goes here
2+
3+
# `variables_metadata.csv` is direct from the
4+
# sensor data processing pipeline
5+
Lx_variables <- readr::read_csv("data-raw/variables_metadata.csv")
6+
Lx_variables <- Lx_variables[c("research_name", "final_units", "description")]
7+
8+
usethis::use_data(Lx_variables, overwrite = TRUE)

data-raw/variables_metadata.csv

Lines changed: 155 additions & 0 deletions
Large diffs are not rendered by default.

data/Lx_variables.rda

3.09 KB
Binary file not shown.

man/Lx_variables.Rd

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

man/read_L1_variable.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)