Dear List,
I have very little experience with lists and am having some very basic problems. I don't know how to add columns to the lower levels of a list, or how to take something from the upper level and add it as a column to the lower level. I am analyzing animal movement data in the package Adehabitat. I have a list of animal movements called "cut.ltr" (class ltraj) that have been divided into a series of "burst" - i.e. movements with no gaps in time over a given threashold. I would like to
1. Add the speed to each item in the list, and also the burst. I can calculate speed as:
sp<-lapply(cut.ltr,function(l){l$dist/l$dt})
This creates a list of the correct size. But I don't know how to add this to my original list. I.e. add a column to the lower levels of the list called "speed".
2. Add the burst to each lower level of the list. It is in the upper level, but I don't know how to access it.
I have tried attribute(), attr(), cut.ltr$"burst", and several other creative guesses.
The first five items in the upper level are below - cut.ltr[1:5], along with head(cut.ltr[[1]]). I would like my final result to have two more columns in cut.ltr[[1]]. One with speed, and the second with burst.
Thanks in advance for your help.
Tim
cut.ltr[1:5]
*********** List of class ltraj ***********
Type of the traject: Type II (time recorded)
Irregular traject. Variable time lag between two locs
Characteristics of the bursts:
id burst nb.reloc NAs date.begin date.end
1 Abigail Abigail.1 47 0 2003-05-31 13:29:59 2003-06-01 00:59:56
2 Abigail Abigail.2 288 0 2003-06-18 17:28:11 2003-06-21 17:14:59
3 Abigail Abigail.3 10 0 2003-08-03 23:33:00 2003-08-04 01:43:58
4 Abigail Abigail.4 43 0 2003-08-04 08:15:25 2003-08-04 18:59:58
5 Abigail Abigail.5 78 0 2003-08-05 00:44:19 2003-08-05 20:15:00