Question with error message

95 views
Skip to first unread message

Sarah Comer

unread,
Aug 3, 2022, 9:37:53 PM8/3/22
to ctmm R user group
Hi Chris

Sorry to trouble you with a very novice question, but I keep getting the error below when I try to run variograms in R-studio. I can't see anything similar in the user group thread, and can't see anything obvious the data I'm importing.  Data was exported from Movebank, and I ran filters to check for duplicates. Time stamps look fine also.

Error in rep(0, nrow(data)) : invalid 'times' argument

Could you please give me an idea where or what I should be looking for to fix?

Thanks !!
Sarah


Christen Fleming

unread,
Aug 4, 2022, 11:22:47 AM8/4/22
to ctmm R user group
Hi Sarah,

I've never seen that error. Please send me a minimal working example (data + script) and I will look into it.

Best,
Chris

Jesse Alston

unread,
Aug 5, 2022, 12:34:23 PM8/5/22
to Christen Fleming, ctmm R user group
Hi Sarah,

This sounds like the error I get when the date does not import as POSIXct. Check str() to make sure the dates didn't import as character or numeric.

Jesse

--
You received this message because you are subscribed to the Google Groups "ctmm R user group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ctmm-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ctmm-user/2711a932-c324-4bf7-99a1-8c8080264733n%40googlegroups.com.


--

Sarah Comer

unread,
Aug 6, 2022, 5:21:50 AM8/6/22
to ctmm R user group
Hi Jesse
Thanks for this! I tried to run again after changing the timestamp string to POSIXct, but had the same error come up.
Have emailed the script and a subset of my data file.
Thanks for your help :-)
Sarah

Matt Keeling

unread,
Jan 3, 2023, 2:44:39 PM1/3/23
to ctmm R user group
Hi Sarah,

I'm running into the same issue. Were you able to figure out what was causing the error?

Christen Fleming

unread,
Jan 3, 2023, 7:53:36 PM1/3/23
to ctmm R user group
Hi Matt,

IIRC, Sarah's issue was just a simple scripting error (bad variable name). Feel free to send me a minimal working example (data + script) and I can take a look at your issue.

Best,
Chris

Sarah Comer

unread,
Jan 3, 2023, 8:29:19 PM1/3/23
to ctmm R user group
Hi Matt, Chris
Yes it was a scripting error my end , with the elements in my list of animals starting with a number.  
Chris suggested I wrapped these, and when I did this all worked well. 
Cheers
Sarah

Matt Keeling

unread,
Jan 4, 2023, 2:37:25 PM1/4/23
to ctmm R user group
Thanks Sarah and Chris for the info. I will pass this along to others that I know that will also be attempting this. 

Chris, I sent you my script and data.

Christen Fleming

unread,
Jan 4, 2023, 3:41:35 PM1/4/23
to ctmm R user group
Hi Matt,

There are multiple individuals in the CSV, and variogram() was being called on the list of individuals rather than on a single individual. I will add an informative error message for that.

CSV <- read.csv("E://OneDrive - Smithsonian Institution/DATA/Matt Keeling/SampleData.csv")
# the timestamps aren't in POSIX format
# timeformat="auto" will *try* to guess the format
DATA <- as.telemetry(CSV,timeformat="auto")
# this is a list of 50 individual telemetry objects
class(DATA)
length(DATA)
class(DATA[[1]])
# so this won't work
SVF <- variogram(DATA)
# this works
SVF <- variogram(DATA[[1]])
zoom(SVF)
# this also works
SVFS <- lapply(DATA,variogram)
zoom(SVFS[[1]])

Best,
Chris
Reply all
Reply to author
Forward
0 new messages