Issue creating camera operation with mutliple problem periods

84 views
Skip to first unread message

Lydia Katsis

unread,
May 23, 2022, 9:30:07 AM5/23/22
to camtrapR
Hello,

I have been trying to use the cameraOperation function with my data, using hasProblems = TRUE, and my column names are labelled:  "Problem1_from" "Problem1_to"   "Problem2_from" "Problem2_to". The function only works if I subset the data frame to include just one pair of problem columns (both work individually). When I try to run the function using the entire data frame, I get the error: Error in as.duration(x) : as.duration is not defined for class 'matrix' 

Attached is a sample of my dataframe. I have tried this using camtrapR "2.0.3" and "2.2.".

My code is here:

df <- read.csv('./Processed data/cam_operability_df.csv', stringsAsFactors = FALSE)

cameraOperation(
  df,
  stationCol = "Station",
  cameraCol= 'CameraID',
  setupCol = "start",
  retrievalCol = "end",
  hasProblems = TRUE,
  byCamera = FALSE,
  allCamsOn = FALSE,
  dateFormat = 'dmy',
  camerasIndependent = FALSE,
  occasionStartTime = 0
)

Error in as.duration(x) : as.duration is not defined for class 'matrix'


Many thanks for any help that can be offered here, I greatly appreciate it.

Lydia
Trial_df.csv

Juergen Niedballa

unread,
May 23, 2022, 12:41:00 PM5/23/22
to camt...@googlegroups.com

Hi Lydia,

I was not able to reproduce your problem, and cameraOperation() worked with the code you sent in v.2.2.0.

Do you have package lubridate installed and loaded? Maybe also try updating lubridate. as.duration() is a lubridate function, so the problem comes from that direction.

Below is the output from the code you shared, plotted with camtrapR:::camopPlot(). Left side is your code, right side is with camerasIndependent= T (for test purposes).

Blue is high effort, turqoise intermediate, and yellow 0. Does this look correct?

Also, the file name in your code is different from the file name you shared. So please make sure that the data frames match.

And also, I see your table uses column names "start" and "end" for your setup and retrieval column. These are also used by an intermediate step inside the function that calculates the duration of problem periods. Try renaming your setup/retrieval columns and see if the error persists.

Best regards,

Jürgen

--
You received this message because you are subscribed to the Google Groups "camtrapR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camtrapr+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/camtrapr/5eda245e-49eb-4fdd-8ed2-04112c4d90bdn%40googlegroups.com.

Lydia Katsis

unread,
May 24, 2022, 2:49:50 AM5/24/22
to camtrapR
Dear Jürgen, 

Thanks so much for your quick response - in deed, just updating lubridate fixed everything.

Many thanks,

Lydia

Reply all
Reply to author
Forward
0 new messages