camrinbraun / HMMoce

hidden markov model for psat data v.1.1
Other
6 stars 7 forks source link

read.wc introducing NAs while opening -PDT.csv files #83

Open marosteg opened 1 year ago

marosteg commented 1 year ago

read.wc() is currently introducing NAs into the object assigned from reading in a -PDT.csv from one of the spearfish. This isn't an issue in the context of running HMMoce but it does yield an error with tags2etuff when using tag_to_etuff(). MWE below (needed file attached):

#Read in metadata
meta <- read.csv('add_shortbillspearfish_meta.csv',header=T)
## format dates
meta$time_coverage_start <- lubridate::parse_date_time(meta$time_coverage_start, orders='Ymd HMS', tz='UTC')
meta$time_coverage_end <- lubridate::parse_date_time(meta$time_coverage_end, orders='Ymd HMS', tz='UTC')

dir <- '~/Google Drive/Shared drives/MPG_WHOI/data/shortbill_spearfish/MiniPAT/'

fish <- list.files(dir)
fish <- fish[-c(8,9)]

i <- 4
  fishID <- fish[i] # specify the individual
  data_dir <- paste(dir, fishID, sep='')

  etuff <- tag_to_etuff(dir=data_dir, meta=meta[which(meta$ptt == fishID),], gpe3 = FALSE)

This yields...

Error in if (nchar(binchar[i]) < 2) binchar[i] <- paste("0", binchar[i], : missing value where TRUE/FALSE needed

...originating on code line 654 due to the IF statement encountering an NA that cannot be used for this TRUE/FALSE test.

add_shortbillspearfish_meta.csv

camrinbraun commented 1 year ago

I cant recreate the issue on my end as everything seems to be working fine. I did have a different (e.g. simplified/updated) version of read.wc() that I pushed to HMMoce here. Hopefully that's the only difference and you're good to go?