Hi everyone,
Here is a sample of my data which features ID (3 periods), date/time, and longitude and latitude co-ordinates.
dput(head(turtles, 20))
structure(list(id = c("Pre", "Pre", "Pre", "Pre", "Pre", "Pre",
"Pre", "Pre", "Pre", "Pre", "Pre", "Pre", "Pre", "Pre", "Pre",
"Pre", "Pre", "Pre", "Pre", "Pre"), date = c("2020-02-03", "2020-02-03",
"2020-02-03", "2020-02-03", "2020-02-03", "2020-02-03", "2020-02-03",
"2020-02-03", "2020-02-03", "2020-02-03", "2020-02-03", "2020-02-03",
"2020-02-03", "2020-02-03", "2020-02-03", "2020-02-03", "2020-02-03",
"2020-02-03", "2020-02-03", "2020-02-03"), time = c("8:30:00 AM",
"8:35:00 AM", "8:40:00 AM", "8:45:00 AM", "8:50:00 AM", "8:55:00 AM",
"9:00:00 AM", "9:05:00 AM", "9:10:00 AM", "9:15:00 AM", "9:20:00 AM",
"9:25:00 AM", "9:30:00 AM", "9:35:00 AM", "9:40:00 AM", "9:45:00 AM",
"9:50:00 AM", "9:55:00 AM", "10:00:00 AM", "10:05:00 AM"), x = c(-34.035352,
-34.035352, -34.035352, -34.035388, -34.035388, -34.035388, -34.036117,
-34.036117, -34.036117, -34.036117, -34.036117, -34.036117, -34.038561,
-34.038561, -34.038561, -34.038561, -34.037691, -34.038561, -34.038562,
-34.038562), y = c(23.273798, 23.273798, 23.273798, 23.274721,
23.274721, 23.274721, 23.274818, 23.274818, 23.274818, 23.274818,
23.274818, 23.274818, 23.273766, 23.273766, 23.273766, 23.273766,
23.273787, 23.273766, 23.272833, 23.272833)), row.names = c(NA,
20L), class = "data.frame")
I would like advise on how to alter this code to reflect the mean distance traveled each day (and shown as the mean for every date available so I have enough to conduct further analyses), and not the mean distance p/d overall for each of the 3 periods (ID). As it stands I am only getting one mean number per ID. Below is the code I have used so far:
total.path.df <- data.frame(turtles.ltraj[[1]], id = attr(turtles.ltraj[[1]], "id"))
for(i in 2:length(turtles.ltraj)) {
total.path.df <- rbind(total.path.df,
data.frame(turtles.ltraj[[i]], id = attr(turtles.ltraj[[i]], "id")))
}
total.path.df$distperday <- total.path.df$dist / (total.path.df$dt/60/60/24)
head(total.path.df)
path.summary <- aggregate(distperday~id, data = total.path.df, FUN = mean)
path.summary$sd <- aggregate(distperday~id, data = total.path.df, FUN = sd)$distperday
Also, if anyone could please advise on further analyses? I will do an LME to compare differences between the 3 periods, but I would love to measure differences in speed of movement and clustering if possible. I have tried numerous packages (e.g. ctmm, movehmm etc) and numerous codes (too many to show here) and can never seem to get what I want, but I'm sure there is a simple way. I have some visualisations already, it is mainly the stats which I can then put into a model that I am after.
Many thanks in advance!