rethomics / damr

Read TriKinetics' DAM data in R
http://rethomics.github.io
6 stars 7 forks source link

Error in load_dam() function and request for help #37

Open katenevin21 opened 3 years ago

katenevin21 commented 3 years ago

I am having issues with loading data into behavr tables with rethomics. I was wondering if someone could point me in the right direction to fixing my problem. When I try to load my data using the load_dam() function I get either of these two errors constantly:

Error in [.data.table(q, , .(regions = list(region_id)), by = c("path", : column or expression 1 of 'by' or 'keyby' is type list. Do not quote column names. Usage: DT[,sum(colC),by=list(colA,month(colB))]

Error in find_dam_first_last_lines(path, start_datetime, stop_datetime, : No data in selected date range

Here is my code:

rm(list = ls())

library(devtools) library(damr) library(behavr)

DATA_DIR <- "C:/Users/Kate/OneDrive/Desktop/Sample" list.files(DATA_DIR, pattern= ".txt|.csv") setwd(DATA_DIR)

metadata <- fread("metadata.txt") dt <- load_dam(metadata)

And here is my metadata region_id DAM file start_datetime stop_datetime genotype sex 1 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 2 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 3 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 4 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 5 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 6 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 7 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 8 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 9 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 10 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 11 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 12 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 13 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 14 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 15 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 16 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 17 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 18 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 19 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 20 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 21 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 22 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 23 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 24 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 25 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 26 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 27 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 28 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 29 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 30 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 31 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 32 21 Monitor 21.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 A male 1 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 2 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 3 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 4 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 5 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 6 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 7 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 8 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 9 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 10 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 11 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 12 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 13 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 14 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 15 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 16 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 17 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 18 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 19 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 20 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 21 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 22 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 23 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 24 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 25 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 26 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 27 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 28 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 29 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 30 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 31 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 32 22 Monitor 22.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 B male 1 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 2 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 3 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 4 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 5 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 6 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 7 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 8 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 9 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 10 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 11 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 12 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 13 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 14 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 15 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 16 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 17 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 18 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 19 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 20 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 21 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 22 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 23 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 24 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 25 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 26 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 27 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 28 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 29 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 30 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 31 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male 32 23 Monitor 23.txt 2021-07-22 10:12:00 2021-07-24 21:10:00 C male

Attached are my three text files, and the .csv and .txt versions of my metadata. Excel keeps changing the time format when I open it up so I prefer to save and use my metadata in the .txt file format. Both versions aren't working for me, so I don't know if that is the issue.

Monitor 21.txt Monitor 22.txt Monitor 23.txt metadata.csv metadata.txt

Thank you!

qgeissmann commented 3 years ago

hi @katenevin21 ,

I was able to reproduce our issue. The date format in your data files is 22-Jul-21 it should be 22 Jul 21. I really don't know why the DAM software generates very incosistent date formats. Half of the issues here seem to result from that with that... Can you try just replacing all - by in your files. Let us know,

katenevin21 commented 3 years ago

Hi @qgeissmann, I replaced the - with spaces, but I am still getting the same error unfortunately.

Here are the updated DAM files attached: Monitor 22.txt Monitor 23.txt Monitor 21.txt

Thank you for replying!

pepelisu commented 2 years ago

I think the problem here is the "by". The line 52 in load_dam.R is calling the "by" method with a vector c("path"... the error says that this is not the right way to give a list to "by" and it should be by=.(path,....) or by=list(path,...) without quoting the column names.

qgeissmann commented 2 years ago

do you think you could try a to send a PR @pepelisu ?

pepelisu commented 2 years ago

As soon as I can test that it works, I can do it. But it will not happen before Monday.