[R] loop with date
Tagmarie
Ramgad82 at gmx.net
Tue Nov 27 17:25:53 CET 2012
Ok, sorry, I thought the more complex details might be confusing and nobody
might answer.
Here is something which looks more like my real dataframe and also what I
want to do with it:
That's my data frame:
myframe <- data.frame (Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00",
"24.09.2012 11:00",
"25.09.2012 09:00", "25.09.2012 10:00",
"25.09.2012 11:00"),
Hunger=c(1,1,2,5,1,6) ,
Longitude=c(8.91617, 8.92700, 8.92711, 8.92722,
8.92733, 8.92744),
Latitude=c(54.5485, 54.5410, 54.5412, 54.5413,
54.5414, 54.5424) ,
AnimalID= c(rep("Ernie")))
head(myframe)
myframestime <- as.POSIXct (strptime(as.character(myframe$Timestamp),
"%d.%m.%Y %H:%M"), tz="GMT")
myframe2 <- cbind (myframe,myframestime)
myframe2$Timestamp <- NULL
myframesxy <- project(cbind(myframe2$Longitude,myframe2$Latitude),"+proj=utm
+zone=32 +ellps=WGS84")
colnames(myframesxy) <- c("Long", "Lat")
myframe3 <- cbind(myframe2, myframesxy)
myframe3$Longitude <- NULL
myframe3$Latitude <- NULL
myframe3
And here is what I want to do with it (make an ltraj element, calculate the
brownian bridge homerange and get the kernel area of it - I take the 95
level):
library(adehabitatHR)
myframe3ltraj <- as.ltraj(myframesxy,myframestime, id=myframe3$AnimalID)
myframeLiker <- liker (myframe3ltraj, sig2=18, rangesig1=c(1,10) )
myframeLiker
MyframeBB <- kernelbb(myframe3ltraj, sig1=4.6036, sig2=18)
kernel.area(MyframeBB, unout=c("km2") )
With the only difference that I don't want to calculate the homerange for
the complete time but for each day.
I could use "subset" and do it for every day by hand.
But I'd have to do it for three month and then again for several animals. So
I thought using a loop for each animal to get the results by date would be
much faster.
Does anybody have any idea?
--
View this message in context: http://r.789695.n4.nabble.com/loop-with-date-tp4650961p4650983.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list