Dear list, I have a table with entries for 20 animals - x and y coordinates to analyze movement with the package adehabitat. The package does all the necessary analyses, but I need to create an object of class ltraj for each animal first. For this kind of object I need to define xy coordinates, id, and few other things for each individual. Now I don't want to run a code 20 times but wanted to include for-loops to have it all run automatically on my entire table. First, create a vector with the variable names (say xy.1, xy.2,..., xy.20), then extract the value "xy.1" and assign a set of coordinates for animal 1, etc.). When I have done this for all variables required to form an ltraj object, I want to create all 20 objects for all 20 animals, by "only" referring to my vector with variable names with the idea that the actual values behind make it into the object. With this piece of code, I was able to extract "xy.1" as name for a data frame containing the coordinates for animal 1: nam_xy <- paste("xy.", 1, sep="") # creates "xy.1" coord.x <- paste("XCM", 1, sep="") coord.y <- paste("YCM", 1, sep="") for (i in 2:20) { nam_xy[i] <- paste("xy.", i, sep="") coord.x[i] <- paste("XCM", i, sep="") coord.y[i] <- paste("YCM", i, sep="") # creates "xy.2", "xy.3", etc. } for (k in 1:20) { assign(nam_xy[[k]],data.mov[,c(coord.x[k],coord.y[k])]) # takes "xy.1" as name for a date frame, "xy.2" for the next, etc. } With this piece of code however, I get error messages. Apparently, the date/time that I defined (one for each row, same timeline for all 20 animals) and nrow(xy) do not have the same length, although when I check it manually length(date) is equal to nrow(xy.1). So it seems to me that I have problems with extracting the right information, that is that when I want to extract xy.1 in the last for-loop, it doesn't automatically give the data frame of x-y- coordinates that I assigned to it earlier.: nam_ltraj <- paste("tr1.",1,sep="") # set up vector of names for ltraj objects for (i in 2:20) { nam_ltraj[i] <- paste("tr1.",i,sep="") # extends vector of names } for (k in 1:20) { assign(nam_ltraj[k], as.ltraj(xy=nam_xy[[k]], date=data.mov$DATE, # assign an object name to an ltraj object with animal specific data id=nam_id[[k]], burst=nam_burst[[k]], typeII=T, slsp=c("remove","missing"))) } Any input on how to solve this is highly appreciated! Jacqueline [[alternative HTML version deleted]]