diff --git a/DESCRIPTION b/DESCRIPTION index 8964d50..5596f30 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,10 @@ Package: monitoR Type: Package Title: Acoustic Template Detection in R -Version: 1.1.3 -Date: 2023-10-13 +Version: 1.1.4 +Date: 2024-03-21 Author: Sasha D. Hafner and Jon Katz , with code for the Fourier transform from the seewave package (by Jerome Sueur, Thierry Aubin, and Caroline Simonis), and code for the readMP3 function from the tuneR package (by Uwe Ligges). Therese Donovan provided creative direction and database design support. -Maintainer: Sasha D. Hafner +Maintainer: Sasha D. Hafner Depends: tuneR, methods Imports: graphics, grDevices, stats, utils Suggests: fftw, parallel, RODBC, knitr diff --git a/R/dbUploadResult.R b/R/dbUploadResult.R index 4b08778..7ddc24b 100644 --- a/R/dbUploadResult.R +++ b/R/dbUploadResult.R @@ -83,7 +83,7 @@ dbUploadResult <- function( pks.L <- rbindf(pks.L) # convert date.time characters to datetime data type format date.time <- unlist(lapply(X = pks.L$date.time, FUN = substr, start = 1, stop = 19)) - tzone <- unlist(lapply(pks.L$date.time, function(x) as.character(x, format = '%Z'))) + tzone <- unlist(lapply(pks.L$date.time, function(x) format(x, format = '%Z'))) # the MySQL query to send the hits to the database query<- paste("INSERT INTO `tblResult` (`pkResultID`, `fkSurveyID`, `fkTemplateID`, `fkPersonID`, `fldDateTime`, `fldTimeZone`, `fldTime`, `fldScore`, `fldOnAmp`, `fldOffAmp`, `fldHit`, `fldVerified`, `fldAnalysisType`, `fldLikelihood`, `fldPosterior`, `fldCutoffValue`) VALUES ('", paste(NULL, "', '", survey.name, "', '", pks.L$template, "', '", analyst, "', '", date.time, "', '", tzone, "', '", pks.L$time, "', '", pks.L$score, "', '", if(length(pks.L$on.amp) == 0) {''} else pks.L$on.amp, "', '", if(length(pks.L$off.amp) == 0) {''} else pks.L$off.amp, "', '", if(length(pks.L$hit) == 0) {''} else pks.L$hit*1, "', '", if(length(pks.L$true) == 0) {-1} else pks.L$true*1, "', '", analysis.type, "', '', '', '", pks.L$score.cutoff, "')", sep = "", collapse = ", ('"), sep = "") diff --git a/R/dbUploadSurvey.R b/R/dbUploadSurvey.R index 3342f32..9d0e1c9 100644 --- a/R/dbUploadSurvey.R +++ b/R/dbUploadSurvey.R @@ -32,7 +32,7 @@ dbUploadSurvey <- function( dm <- substr(survey.meta[, 'fldSurveyName'], start = 8, stop = 24) dm <- as.Date(dm, format = "%Y-%m-%d_%H%M%S") dm <- as.POSIXct(dm, tz = tz, format = "%Y-%m-%d_%H%M%S %Z") - survey.meta['fldOriginalDateModified'] <- as.character(dm, format = "%Y-%m-%d_%H%M%S %Z") + survey.meta['fldOriginalDateModified'] <- format(dm, format = "%Y-%m-%d_%H%M%S %Z") } else stop('No "fldOriginalDateModified" in metadata and file name does not have date and time info.') } if(!update.query) { diff --git a/R/fileCopyRename.R b/R/fileCopyRename.R index 17ef469..250b2c3 100644 --- a/R/fileCopyRename.R +++ b/R/fileCopyRename.R @@ -20,8 +20,8 @@ function( copy = TRUE # Set to FALSE to rename files without moving ){ - if(missing(csv.name) & length(loc.prefix) == 1) csv.name <- paste(loc.prefix, '_', as.character(Sys.time(), format = '%Y-%m-%d'), '.csv', sep = '') - else csv.name <- paste('metadata_', as.character(Sys.time(), format = '%Y-%m-%d'), '.csv', sep = '') + if(missing(csv.name) & length(loc.prefix) == 1) csv.name <- paste(loc.prefix, '_', format(Sys.time(), format = '%Y-%m-%d'), '.csv', sep = '') + else csv.name <- paste('metadata_', format(Sys.time(), format = '%Y-%m-%d'), '.csv', sep = '') if (all(nchar(loc.prefix) != 6)) stop(paste('loc.prefix must be 6 characters, got', paste0(loc.prefix, collapse = ", "))) diff --git a/R/mp3Subsamp.R b/R/mp3Subsamp.R index a1846cd..9a8e14a 100644 --- a/R/mp3Subsamp.R +++ b/R/mp3Subsamp.R @@ -27,7 +27,7 @@ mp3Subsamp <- function( if (length(system(command = "mp3splt -h", intern = TRUE))<10) stop("'mp3splt' not found; download mp3splt at\nhttp://mp3splt.sourceforge.net/mp3splt_page/home.php\n") - if(missing(csv.name)) csv.name <- paste(loc.prefix, '_', as.character(Sys.time(), format = '%Y-%m-%d'), '.csv', sep = '') + if(missing(csv.name)) csv.name <- paste(loc.prefix, '_', format(Sys.time(), format = '%Y-%m-%d'), '.csv', sep = '') if (nchar(loc.prefix) != 6) {stop(paste('loc.prefix must be 6 characters, got', loc.prefix))} @@ -77,8 +77,8 @@ mp3Subsamp.one <- function( surv.end <- surv.start+duration # predict the new mdates and file names for each subsurvey time.remain <- rec.dur-surv.end - new.file.mdates <- as.character(file.mdate-time.remain, format = '%Y-%m-%d %H%M%S %Z') - new.mdates <- as.character(file.mdate-time.remain, format = '%Y-%m-%d_%H%M%S_%Z') + new.file.mdates <- format(file.mdate-time.remain, format = '%Y-%m-%d %H%M%S %Z') + new.mdates <- format(file.mdate-time.remain, format = '%Y-%m-%d_%H%M%S_%Z') filenames <- paste(loc.prefix, '_', new.mdates, sep = "") # Format seconds to mm.ss.xx, where xx are hundredths, for mp3splt surv.start <- lapply(surv.start, function(x) { diff --git a/R/viewSpec.R b/R/viewSpec.R index f29fba4..b0bfb41 100644 --- a/R/viewSpec.R +++ b/R/viewSpec.R @@ -127,9 +127,9 @@ function( t.bin.ticks <- pretty(t.bins, n = 6) t.bin.ticks <- pretty(t.bins, n = 10, min.n = 5) if(page.length<5) { - axis(1, at = t.bin.ticks/t.step, labels = as.character(as.POSIXct(t.bin.ticks+start.time, origin = "1960-01-01", tz = "GMT"), format = '%H:%M:%OS2')) + axis(1, at = t.bin.ticks/t.step, labels = format(as.POSIXct(t.bin.ticks+start.time, origin = "1960-01-01", tz = "GMT"), format = '%H:%M:%OS2')) } else { - axis(1, at = t.bin.ticks/t.step, labels = as.character(as.POSIXct(t.bin.ticks+start.time, origin = "1960-01-01", tz = "GMT"), format = '%H:%M:%S')) + axis(1, at = t.bin.ticks/t.step, labels = format(as.POSIXct(t.bin.ticks+start.time, origin = "1960-01-01", tz = "GMT"), format = '%H:%M:%S')) } if(!quiet && channel == 'both') {return(list(t = t.step, f = frq.step, tb = n.t.bins, amp = amp, whicht = which.t.bins, whichf = which.frq.bins, ampR = amp.R))#, tw = t.wave))