Я использую код для начальной загрузки, чтобы найти разницу в моделях активности между двумя видами.Я получаю сообщение об ошибке «подписка за пределами».Я вставил код, который я использую ниже.Есть идеи, где я ошибся?
#Load packages
library(data.table)
library(activity)
library(overlap)
#Load dataset
<-fread(file="data.csv")
names(data) #these are the column names
unique(data$Subproject) #these are the counties in the dataset
##### Turn the time into Radians
setDT(data)[,paste0("Begin.Time",1:2):= tstrsplit(Begin," ")] #Splits the time stamp into Date and Time Columns
setnames(data, old = c('Begin.Time1','Begin.Time2'), new = c('Date','Time')) #Renames the new columns
setDT(data)[,paste0("Times",1:3):= tstrsplit(Time,":")]
data$hours<-as.numeric(data$Times1)
data$mins<-as.numeric(data$Times2)
data$seconds<-as.numeric(data$Times3)
data$hours<-data$hours * 60
data$seconds<-data$seconds / 60
data$totalminutes<-data$hours + data$mins + data$seconds
data[,!c("Times1","Times2","Times3"), with=F]
data$totalminutes<-apply(data, MARGIN=2, FUN=function(x) (data$totalminutes-min(data$totalminutes))/diff(range(data$totalminutes)))
summary(data$totalminutes)
data$radians <- data$totalminutes * 2 * pi #This turns total minutes into radians
######################## Bootstrapping ###################################
Deer.bootstrap <- resample (Deer$radians, 1000)
dim(Deer.bootstrap)
coyote.bootstrap <- resample (Coyote$radians, 1000)
dim(coyote.bootstrap)
coyote.Deer.boot <- bootEst(coyote.bootstrap, Deer.bootstrap, adjust = c (NA,1,NA))
dim(coyote.Deer.boot)
Boot.mean <- colMeans (coyote.Deer.boot)
Boot.mean
Boot.Bias <- Boot.mean -D.hat.estimates
Boot.Bias
####################### confidence intervals #############################
#use bootCI to calculate confidence intervals for D.hat / boot data
Conf.deer.coyote <- coyote.Deer.boot [, 2]
bootCI(D.hat.estimates[2], Conf.deer.coyote, conf = 0.95)
######## Calculating difference between 2 species in relation to time #####
#to compare activity across certain desired parts of the day per species: reps
# represents bootstrapping amount
fdeer <- fitact (Deer$radians, reps = 500)
compareTimes(fdeer, c(5.5,6, 0.5, 1))
Вот ошибка, которую я получаю из последней строки кода (все остальное работает хорошо):
Error in fit@pdf[, 3] : subscript out of bounds