[answers inline] On 18 August 2017 at 20:08, Dagmar <ramga...@gmx.net> wrote: > > myframe<- data.frame (ID=c("Ernie", "Ernie","Ernie","Ernie"), > Timestamp=c("24.09.2012 08:00", "24.09.2012 09:00", "24.09.2012 10:00", > "25.09.2012 10:00"), Longitude=c("8.481","8.482","8.483","8.481"), > Latitude=c("54.753","54.753","54.752","54.751") > ) > myframe > > # Now this is where my loop is supposed to start. In this example I want > to run the following functions 3 times. (In real life more often.) How do I > do that? > > library(adehabitatHR) > library(rgdal) >
you should use require instead of library if this is a script, require returns boolean, whereas library raises an exception. mysample <- myframe[sample(1:nrow(myframe), 3,replace=FALSE),] > mysample > mysampletime <- as.POSIXct (strptime(as.character(mysample$Timestamp), > "%d.%m.%Y %H:%M"), tz="GMT") > mysamplexy <- project (cbind (mysample$Longitude, mysample$Latitude), > "+proj=utm +zone=32 +ellps=WGS84") > colnames(mysamplexy) <- c ("xCord", "yCord") > ID <- mysample$ID > datltraj <- as.ltraj(mysamplexy, mysampletime, id=ID) > Ddat <- BRB.D(datltraj, Tmax=21600, Lmin=36) > BRBdat <- BRB(datltraj, D= Ddat,type=c("UD"),Tmax=21600,Lmin=36, hmin=100) > kernel.area(BRBdat, unout=c("km2")) > > # unfortunately my data are not a very good example. Sorry about that. But > I guess you know what I mean. > > # Because I wish to run the functions three times I do want a data frame > (or matrix) in the end, which includes the results (kernel areas): That > means 12 columns and the three lines. > > # How do I do that? > Use the rep function, with times being 3? Best of luck -- H -- OpenPGP: https://sks-keyservers.net/pks/lookup?op=get&search=0xFEBAD7FFD041BBA1 If you wish to request my time, please do so using http://bit.ly/hd1ScheduleRequest. Si vous voudrais faire connnaisance, allez a http://bit.ly/hd1ScheduleRequest. <https://sks-keyservers.net/pks/lookup?op=get&search=0xFEBAD7FFD041BBA1>Sent from my mobile device Envoye de mon portable [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.