@@ -15,20 +15,20 @@ clean_otn_deployment <- function(deployment) {
15
15
# Find which sheet has deployment data. If none are explicitly labeled, assume
16
16
# it's sheet 1
17
17
sheet_id <- grep(" dep" , readxl :: excel_sheets(deployment ),
18
- ignore.case = T , value = T
18
+ ignore.case = T , value = T
19
19
)
20
20
if (length(sheet_id ) == 0 ) {
21
21
sheet_id <- 1
22
22
}
23
23
24
24
# Check for header: If the first row has no columns, it likely contains it.
25
25
if (ncol(readxl :: read_excel(deployment ,
26
- sheet = sheet_id ,
27
- range = " A1"
26
+ sheet = sheet_id ,
27
+ range = " A1"
28
28
)) == 0 ) {
29
29
deployment <- readxl :: read_excel(deployment ,
30
- sheet = sheet_id ,
31
- skip = 3
30
+ sheet = sheet_id ,
31
+ skip = 3
32
32
)
33
33
} else {
34
34
deployment <- readxl :: read_excel(deployment , sheet = sheet_id )
@@ -38,12 +38,12 @@ clean_otn_deployment <- function(deployment) {
38
38
check_head <- read.csv(deployment , nrows = 1 , check.names = FALSE )
39
39
if (ncol(check_head ) > length(unique(names(check_head )))) {
40
40
deployment <- read.csv(deployment ,
41
- skip = 3 ,
42
- na.strings = c(" NA" , " " )
41
+ skip = 3 ,
42
+ na.strings = c(" NA" , " " )
43
43
)
44
44
} else {
45
45
deployment <- read.csv(deployment ,
46
- na.strings = c(" NA" , " " )
46
+ na.strings = c(" NA" , " " )
47
47
)
48
48
}
49
49
} else {
@@ -63,10 +63,10 @@ clean_otn_deployment <- function(deployment) {
63
63
deployment $ recover_date_time <- convert_times(deployment $ recover_date_time )
64
64
65
65
deployment <- deployment [! is.na(deployment $ deploy_date_time ) &
66
- ! is.na(deployment $ recover_date_time ), ]
66
+ ! is.na(deployment $ recover_date_time ), ]
67
67
deployment $ receiver <- paste(deployment $ ins_model_no ,
68
- deployment $ ins_serial_no ,
69
- sep = " -"
68
+ deployment $ ins_serial_no ,
69
+ sep = " -"
70
70
)
71
71
deployment $ stationname <- deployment $ station_no
72
72
@@ -86,16 +86,15 @@ clean_otn_deployment <- function(deployment) {
86
86
87
87
# ' @rdname utilities-make
88
88
# ' @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 ) {
92
91
# check if Excel format
93
92
# Assumes that it starts with 5 numbers
94
- if (grepl(' ^\\ d{5}' , x )) {
93
+ if (grepl(" ^\\ d{5}" , x )) {
95
94
as.POSIXct(
96
95
as.numeric(x ) * (60 * 60 * 24 ),
97
96
tz = " UTC" ,
98
- origin = ' 1899-12-30'
97
+ origin = " 1899-12-30"
99
98
)
100
99
} else {
101
100
as.POSIXct(
@@ -123,8 +122,8 @@ provided_file_unzip <- function(files, temp_dir) {
123
122
to_unzip ,
124
123
function (. ) {
125
124
unzip(. ,
126
- exdir = temp_dir ,
127
- setTimes = FALSE
125
+ exdir = temp_dir ,
126
+ setTimes = FALSE
128
127
)
129
128
}
130
129
)
@@ -158,7 +157,7 @@ write_to_tempdir <- function(type, files, temp_dir) {
158
157
# # Write file to temporary directory
159
158
filepath <- file.path(temp_dir , paste0(type , " .csv" ))
160
159
write.csv(files , filepath ,
161
- row.names = F
160
+ row.names = F
162
161
)
163
162
164
163
0 commit comments