-
Notifications
You must be signed in to change notification settings - Fork 76
/
api_csv.R
32 lines (32 loc) · 975 Bytes
/
api_csv.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#' @title Transform a CSV into a samples file
#' @name .csv_get_samples
#' @author Gilberto Camara
#' @keywords internal
#' @noRd
#' @param csv_file CSV that describes the data to be retrieved.
#' @return A tibble with information the samples to be retrieved
#'
.csv_get_samples <- function(csv_file) {
# read sample information from CSV file and put it in a tibble
samples <- tibble::as_tibble(
utils::read.csv(
file = csv_file,
stringsAsFactors = FALSE
)
)
# pre-condition - check if CSV file is correct
.check_samples(samples)
# select valid columns
samples <- dplyr::select(
samples,
.conf("df_sample_columns")
)
# transform to date
samples <- dplyr::mutate(
samples,
start_date = as.Date(.data[["start_date"]]),
end_date = as.Date(.data[["end_date"]])
)
class(samples) <- c("sits", class(samples))
return(samples)
}