Skip to content

Commit

Permalink
Increment version number to 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
JZauner committed Oct 9, 2024
1 parent 15db999 commit be4cd48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: LightLogR
Title: Process Data from Wearable Light Loggers and Optical Radiation Dosimeters
Version: 0.4.1
Version: 0.4.2
Authors@R: c(
person("Johannes", "Zauner",
email = "[email protected]", role = c("aut", "cre"),
Expand Down Expand Up @@ -32,6 +32,7 @@ Imports:
ggsci,
ggtext,
hms,
janitor,
lubridate,
magrittr,
pkgload,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# LightLogR 0.4.2

# LightLogR 0.4.1

* added support for OcuWEAR devices
Expand Down
18 changes: 18 additions & 0 deletions R/import_LL.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#' column. If the column is not present it will add this column and fill it
#' with the filename of the importfile (see param `auto.id`).
#' * `print_n` can be used if you want to see more rows from the observation intervals
#' * `remove_duplicates` can be used if identical observations are present within or across multiple files. The default is `FALSE`. The function keeps only unique observations (=rows) if set to' TRUE'. This is a convenience implementation of [dplyr::distinct()].
#'
#' @param ... Parameters that get handed down to the specific import functions
#' @param device From what device do you want to import? For a few devices,
Expand Down Expand Up @@ -282,6 +283,7 @@ imports <- function(device,
locale = readr::default_locale(),
silent = FALSE,
print_n = 10,
remove_duplicates = FALSE,
... =
),
#function expression
Expand Down Expand Up @@ -353,6 +355,22 @@ imports <- function(device,
)
}

#if there are duplicate rows, remove them and print an info message
duplicates <- suppressMessages(janitor::get_dupes(data, -file.name) %>% nrow())
orig_rows <- data %>% nrow()

if(duplicates > 0 & remove_duplicates) {
data <- data %>% dplyr::distinct(dplyr::pick(-file.name),.keep_all = TRUE)
cat(paste0(format(orig_rows - nrow(data), big.mark = "'"), " duplicate rows were removed during import.\n"))
}

#if there are untreated duplicate rows, give a warning
if(duplicates > 0 & !remove_duplicates) {
messages <- paste0(format(duplicates, big.mark = "'"), " rows in your dataset(s) are identical to at least one other row. This causes problems during analysis. Please set `remove_duplicates = TRUE` during import. \nIf you still want to import the data as is and it failed with an error, try setting `auto.plot = FALSE`. You may want to do this to find out which entries are duplicates. Use `{replace_with_data_object} %>% janitor::get_dupes(-file.name) on your imported dataset.\n")
cat(messages)
warning(messages)
}

#if dst_adjustment is TRUE, adjust the datetime column
if(dst_adjustment) {
data <- data %>% dst_change_handler(filename.colname = file.name)
Expand Down

0 comments on commit be4cd48

Please sign in to comment.