Skip to content

Commit 82cb5f7

Browse files
committed
Merge branch 'issue-10' of https://github.com/mhpob/otndo into issue-10
2 parents 6e54d63 + 94a60da commit 82cb5f7

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

R/utilities_make.R

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ clean_otn_deployment <- function(deployment) {
1515
# Find which sheet has deployment data. If none are explicitly labeled, assume
1616
# it's sheet 1
1717
sheet_id <- grep("dep", readxl::excel_sheets(deployment),
18-
ignore.case = T, value = T
18+
ignore.case = T, value = T
1919
)
2020
if (length(sheet_id) == 0) {
2121
sheet_id <- 1
2222
}
2323

2424
# Check for header: If the first row has no columns, it likely contains it.
2525
if (ncol(readxl::read_excel(deployment,
26-
sheet = sheet_id,
27-
range = "A1"
26+
sheet = sheet_id,
27+
range = "A1"
2828
)) == 0) {
2929
deployment <- readxl::read_excel(deployment,
30-
sheet = sheet_id,
31-
skip = 3
30+
sheet = sheet_id,
31+
skip = 3
3232
)
3333
} else {
3434
deployment <- readxl::read_excel(deployment, sheet = sheet_id)
@@ -38,12 +38,12 @@ clean_otn_deployment <- function(deployment) {
3838
check_head <- read.csv(deployment, nrows = 1, check.names = FALSE)
3939
if (ncol(check_head) > length(unique(names(check_head)))) {
4040
deployment <- read.csv(deployment,
41-
skip = 3,
42-
na.strings = c("NA", "")
41+
skip = 3,
42+
na.strings = c("NA", "")
4343
)
4444
} else {
4545
deployment <- read.csv(deployment,
46-
na.strings = c("NA", "")
46+
na.strings = c("NA", "")
4747
)
4848
}
4949
} else {
@@ -63,10 +63,10 @@ clean_otn_deployment <- function(deployment) {
6363
deployment$recover_date_time <- convert_times(deployment$recover_date_time)
6464

6565
deployment <- deployment[!is.na(deployment$deploy_date_time) &
66-
!is.na(deployment$recover_date_time), ]
66+
!is.na(deployment$recover_date_time), ]
6767
deployment$receiver <- paste(deployment$ins_model_no,
68-
deployment$ins_serial_no,
69-
sep = "-"
68+
deployment$ins_serial_no,
69+
sep = "-"
7070
)
7171
deployment$stationname <- deployment$station_no
7272

@@ -86,16 +86,15 @@ clean_otn_deployment <- function(deployment) {
8686

8787
#' @rdname utilities-make
8888
#' @keywords internal
89-
convert_times <- function(date_time){
90-
91-
check_times <- function(x){
89+
convert_times <- function(date_time) {
90+
check_times <- function(x) {
9291
# check if Excel format
9392
# Assumes that it starts with 5 numbers
94-
if (grepl('^\\d{5}', x)) {
93+
if (grepl("^\\d{5}", x)) {
9594
as.POSIXct(
9695
as.numeric(x) * (60 * 60 * 24),
9796
tz = "UTC",
98-
origin = '1899-12-30'
97+
origin = "1899-12-30"
9998
)
10099
} else {
101100
as.POSIXct(
@@ -123,8 +122,8 @@ provided_file_unzip <- function(files, temp_dir) {
123122
to_unzip,
124123
function(.) {
125124
unzip(.,
126-
exdir = temp_dir,
127-
setTimes = FALSE
125+
exdir = temp_dir,
126+
setTimes = FALSE
128127
)
129128
}
130129
)
@@ -158,7 +157,7 @@ write_to_tempdir <- function(type, files, temp_dir) {
158157
## Write file to temporary directory
159158
filepath <- file.path(temp_dir, paste0(type, ".csv"))
160159
write.csv(files, filepath,
161-
row.names = F
160+
row.names = F
162161
)
163162

164163

tests/testthat/test-convert_times.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
test_datetime <- as.POSIXct("2020-04-09T11:04:59", tz = "UTC",
2-
format = "%Y-%m-%dT%H:%M:%S")
1+
test_datetime <- as.POSIXct("2020-04-09T11:04:59",
2+
tz = "UTC",
3+
format = "%Y-%m-%dT%H:%M:%S"
4+
)
35

46
test_that("converts ISO 8601", {
57
expect_equal(

0 commit comments

Comments
 (0)