And here comes the entire script.
Hope it will help.

#hr_data$date <- paste(hr_data$day, hr_data$month, hr_data$year, sep="-")
hr_data$Date_time2 <- paste(hr_data$UTC_DATE, hr_data$UTC_TIME, sep=" ")
hr_data$Date_time2 <- as.POSIXct(strptime((hr_data$Date_time2), "%d/%m/%Y
%H:%M:%S"), tz="GMT")
hr_data$julianday <- strftime(hr_data$Date_time2, format = "%j")

coordinates(hr_data) <- c("X", "Y")
RT90_2.5gV <- CRS("+init=epsg:3021")
proj4string(hr_data) <- RT90_2.5gV

homerange <- list()
perc=0.8 # percent of href in the HR calculations
#perc1=1
n_min=10 #I use 25 as min locations for yearly HR
info <- data.frame() # a data frame to store the information about no.
locations and months monitored
unique_id <- unique(hr_data$idnr)
#unique_id <- levels(unique(hr_data$idnr))

for(i in 1:length(unique_id)) #The first foor-loop tells to select one
single individual, from the
  #first to the last in the unique_id vector
{
  id <- unique_id[i] #get the id_nr, used to subset location data
  data <- hr_data[hr_data$idnr == id,] #use the id nr to subset the
SPdataframe to get locations for only that individual
  unique_year <- unique(data$Year) # get a vector with the unique years
that particular animal has locations from, used to create next loop

  for(j in 1:length(unique_year))# The first foor-loop tells to do things
for one single year, from the first to the last year thet particular
individual has been monitored
  {
    year <- unique_year[j] #get the year and because year data set
(hr_data) only contains locations from the years when the females gave
birth you will get the years with birth period for this particular animal
    data_year <- data[(data$Year == year),] # Here I use the year to get
only the locations I want, but you should do a different subset, see below
    count <- seq(1,366,by=7)

    for(k in 1:length(count))
    {
      count_new <- count[k]
      data_biweek <-
data_year[((as.integer(data_year$julianday))>=count_new) &
((as.integer(data_year$julianday))<(count_new+7)),]
      loc <- nrow(data_biweek)

      if(n_min <= nrow(data_biweek)) {
        data_biweek$idnr<-as.character(data_biweek$idnr)
        ud <- kernelUD(data_biweek[,1], h="href", grid=100, extent=4)
        h <- perc*ud[[1]]@h$h #get new h, 100% of href or else
        ud_new1 <- kernelUD(data_biweek[,1], h=h, grid=100, extent=1)
        kernel90_biweek <- getverticeshr(ud_new1, percent=95, unout="km2")
        homerange[[paste("hr90", id, year, count_new, sep = "_")]] <-
kernel90_biweek

        area <- kernel90_biweek[[2]]

        info_new_bis_biweek <- c(id,year,count_new,loc,area)
        info <- data.frame(rbind(info, info_new_bis_biweek))
      }



    } #end k-loop
  } #end j-loop
} #end i-loop

There I am estimating home-ranges for a period of 7 days!

CHeers,


2013/11/7 Dylann Kersusan <kersusan.dylann@gmail.com>

> Sorry for the first thread, it was incomplete! There you have a sample of
> my dataset and coding.
>
> Cheers,
>
>
> 2013/11/7 Dylann Kersusan <kersusan.dylann@gmail.com>
>
>> Dear list,
>>
>> I am running a script on my computer to estimate kernelUDs for several
>> individuals and several years (from GPS relocations). I am using the
>> getverticeshr() function to extract home range contours, and for some
>> reasons I end up having this error message:
>>
>> Erreur dans re[[i]] : indice hors limites
>>
>> in french, the english translation would be:
>>
>> Error in re [[i]]: index out of range
>>
>> Here you have a sample of my dataset:
>>
>> idnr name species sex collarID UTC_DATE Day Month Year UTC_TIME
>> UTC_DATE_TIME X Y check checkinfo HEIGHT Date_time
>> J-01129 Sivva wolverine FALSE 8277 13/01/2010 13 1 2010 20:01:48 13/01/2010
>> 20:01:48 1603644 7440041 0 0 763 13/01/2010 20:01:48
>> J-01129 Sivva wolverine FALSE 8277 14/01/2010 14 1 2010 02:01:21 14/01/2010
>> 02:01:21 1603740 7440591 0 0 676 14/01/2010 02:01:21
>> J-01129 Sivva wolverine FALSE 8277 14/01/2010 14 1 2010 11:01:47 14/01/2010
>> 11:01:47 1603748 7440202 0 0 801 14/01/2010 11:01:47
>> J-01129 Sivva wolverine FALSE 8277 14/01/2010 14 1 2010 20:01:09 14/01/2010
>> 20:01:09 1603257 7439872 0 0 799 14/01/2010 20:01:09
>> J-01129 Sivva wolverine FALSE 8277 15/01/2010 15 1 2010 02:00:23 15/01/2010
>> 02:00:23 1602251 7438341 0 0 1027 15/01/2010 02:00:23
>> J-01129 Sivva wolverine FALSE 8277 15/01/2010 15 1 2010 11:00:42 15/01/2010
>> 11:00:42 1600433 7439602 0 0 765 15/01/2010 11:00:42
>> J-01129 Sivva wolverine FALSE 8277 15/01/2010 15 1 2010 20:01:19 15/01/2010
>> 20:01:19 1600605 7428709 0 0 920 15/01/2010 20:01:19
>> J-01129 Sivva wolverine FALSE 8277 16/01/2010 16 1 2010 11:00:51 16/01/2010
>> 11:00:51 1601455 7426934 0 0 472 16/01/2010 11:00:51
>> J-01129 Sivva wolverine FALSE 8277 17/01/2010 17 1 2010 02:01:17 17/01/2010
>> 02:01:17 1607980 7433757 0 0 782 17/01/2010 02:01:17
>> J-01129 Sivva wolverine FALSE 8277 17/01/2010 17 1 2010 11:00:42 17/01/2010
>> 11:00:42 1608667 7432781 0 0 669 17/01/2010 11:00:42
>>
>> The error might come from these lines of code:
>>
>> if(n_min <= nrow(data_biweek)) {
>>         data_biweek$idnr<-as.character(data_biweek$idnr)
>>         ud <- kernelUD(data_biweek[,1], h="href", grid=100, extent=4)
>>         h <- perc*ud[[1]]@h$h #get new h, 100% of href or else
>>         ud_new1 <- kernelUD(data_biweek[,1], h=h, grid=100, extent=1)
>>         kernel90_biweek <- getverticeshr(ud_new1, percent=95, unout="km2")
>>         homerange[[paste("hr90", id, year, count_new, sep = "_")]] <-
>> kernel90_biweek
>>
>>         area <- kernel90_biweek[[2]]
>>
>>         info_new_bis_biweek <- c(id,year,count_new,loc,area)
>>         info <- data.frame(rbind(info, info_new_bis_biweek))
>>       }
>>
>> Thanks a lot.
>>
>>
>> 2013/11/7 Dylann Kersusan <kersusan.dylann@gmail.com>
>>
>>> Dear list,
>>>
>>> I am running a script on my computer to estimate kernelUDs for several
>>> individuals and several years (from GPS relocations). I am using the
>>> getverticeshr() function to extract home range contours, and for some
>>> reasons I end up having this error message:
>>>
>>> Erreur dans re[[i]] : indice hors limites
>>>
>>> in french, the english translation would be:
>>>
>>> Error in re [[i]]: index out of range
>>>
>>> --
>>> Dylann Kersusan
>>> Master Biodiversity and Conservation
>>> Zoology dept. Stockholm University
>>> --
>>> Grimsö Wildlife Research Center
>>> Ecology dept. SLU
>>> Riddarhyttan-Sweden
>>>
>>
>>
>>
>> --
>> Dylann Kersusan
>> Master Biodiversity and Conservation
>> Zoology dept. Stockholm University
>> --
>> Grimsö Wildlife Research Center
>> Ecology dept. SLU
>> Riddarhyttan-Sweden
>>
>
>
>
> --
> Dylann Kersusan
> Master Biodiversity and Conservation
> Zoology dept. Stockholm University
> --
> Grimsö Wildlife Research Center
> Ecology dept. SLU
> Riddarhyttan-Sweden
>



-- 
Dylann Kersusan
Master Biodiversity and Conservation
Zoology dept. Stockholm University
--
Grimsö Wildlife Research Center
Ecology dept. SLU
Riddarhyttan-Sweden

	[[alternative HTML version deleted]]

