Dear Adam,
I'm not yet familiar with the infolocs components of the new ltraj.
However, there is now a new set of functions ld/dl to convert from ltraj
to data frames that are really handy. You should have a look at these.
Try the following example, expanding from what I already sent:
data(puechcirc)
i <- fpt(puechcirc, seq(300,1000, length=30))
bla <- do.call(rbind, i)
na <- unlist(lapply(puechcirc, function(i) sum(!is.na(i[, 1]))))
infolocs(puechcirc) <- list(data.frame(matrix(rnorm(80*4), ncol = 4)),
data.frame(matrix(rnorm(69*4), ncol = 4)),
data.frame(matrix(rnorm(66*4), ncol = 4)))
bli <- ld(puechcirc)
blu <- data.frame(bla, bli[!is.na(bli$x), ])
Note that you don't even need to fill in $burst by hand.
Hope this helps,
Mathieu.
Le 19/02/2011 14:30, Adam T. Ford a écrit :
Hello Mathieu,
Following up from our previous postings, and with the new LT package
available, I am trying to add the 'infolocs' into the FPT output.
I maxed out the memory, so Im sure I did this wrong. All I was trying to
do is have a casewise listing of the infolocs metadata attached to each
row of the FPT output.
This is what I tried, using infolocs() in the way you used used burst().
i.10m <- fpt(na.10m, seq(5, 50, 5), units = "hours")
exp.10mFPT <- do.call (rbind, i.10m)
na <- unlist(lapply(na.10m, function(i) sum(!is.na <http://is.na>(i[, 1]))))
exp.10mFPT$burst <- rep(burst(na.10m), times = na)
exp.10mFPT$info <- rep(infolocs(na.10m), times = na)
Any help is appreciated!
Thanks,
Adam
On Mon, Jan 31, 2011 at 5:12 PM, Mathieu Basille
<basi...@ase-research.org <mailto:basi...@ase-research.org>> wrote:
Sorry, there is a mistake in the code: should be 'times' instead of
'each' in the rep line:
bla$burst <- rep(burst(puechcirc), times = na)
Mathieu.
Le 2011-01-31 19:04, Adam T. Ford a écrit :
> gorgeous code Mathieu, thanks much!
>
> On Mon, Jan 31, 2011 at 4:13 PM, Mathieu Basille
> <basi...@ase-research.org <mailto:basi...@ase-research.org>
<mailto:basi...@ase-research.org <mailto:basi...@ase-research.org>>>
wrote:
>
> The difference comes from the NA (fpt first removes any NAs
in the
> coordinates).
>
> Something along that line should work:
>
> data(puechcirc)
> i <- fpt(puechcirc, seq(300,1000, length=30))
> bla <- do.call(rbind, i)
>
> na <- unlist(lapply(puechcirc, function(i) sum(!is.na
<http://is.na>
> <http://is.na>(i[, 1]))))
> bla$burst <- rep(burst(puechcirc), each = na)
>
>
> Hope this helps,
> Mathieu.
>
>
> Le 2011-01-31 18:04, Adam T. Ford a écrit :
> > Hello Mathieu and Animovers,
> >
> > Thank you for that reply and your interest.
> > You are quite correct, there is a text file produced!
> > Still, I am not sure which rows belong to which animals/bursts.
> Do you
> > know of a way to carry this information from the ltraj object
into the
> > output of a fipati object?
> > Since I coerced my original dataframe into a regular timeseries
there
> > will be several observations that the function sett0 ()
filled in,
> > correct? This is why I have more rows in the fpt () output then
in my
> > raw data.
> > But Im not sure how to match the rows of the ltraj object with the
> > output of fpt().
> > In my mind, it would make sense to write.table () the ltraj
> object, and
> > match rows with the fpt() output.
> > But when I tried I get:
> > ERROR: arguments imply differing number of rows
> >
> >
> > Thanks again,
> >
> >
> > Adam
> >
> > On Mon, Jan 31, 2011 at 3:45 PM, Mathieu Basille
> > <basi...@ase-research.org <mailto:basi...@ase-research.org>
<mailto:basi...@ase-research.org <mailto:basi...@ase-research.org>>
> <mailto:basi...@ase-research.org
<mailto:basi...@ase-research.org> <mailto:basi...@ase-research.org
<mailto:basi...@ase-research.org>>>>
> wrote:
> >
> > Dear Adam,
> >
> > What's wrong with the output of write.table? I can do the
> following
> > without any error (building upon the example of fpt):
> >
> > data(puechcirc)
> > i <- fpt(puechcirc, seq(300,1000, length=30))
> > bla <- do.call(rbind, i)
> > write.table(bla, file = "bla.txt")
> >
> > And the resulting text file is fine.
> >
> > Mathieu.
> >
> >
> > Le 2011-01-31 17:37, Adam T. Ford a écrit :
> > > Hello Animovers,
> > >
> > > I am having trouble extracting the results of the fpt ()
> function.
> > > As far as I can tell, this function is working correctly,
> all the
> > plots
> > > appear in order etc.
> > >
> > > I have 7 animals with different sampling periods representing a
> > total of
> > > 48 'bursts'. So I have 48 dataframes assembled as a "fipati"
> object.
> > > My problem is that I am not sure how to compile a list of
> multiple
> > > dataframes in way that I can analyze it statistically, or
> look at it
> > > completely.
> > >
> > > I have tried (for example):
> > >
> > > i <- fpt(puechcirc, seq(5, 100, 5), units = "hours")
> > > do.call(rbind, i)
> > >
> > > and then I tried write.table() to export to a text file but
> got a
> > series
> > > of errors, for example:
> > >
> > > 23] WARNING: Warning: \U used without hex digits
> > > Warning: '\A' is an unrecognized escape in a character
> string
> > > Warning: '\D' is an unrecognized escape in a character
> string
> > > Warning: '\D' is an unrecognized escape in a character
> string
> > > Warning: '\S' is an unrecognized escape in a character
> string
> > > Warning: '\J' is an unrecognized escape in a character string
> > >
> > > Has anyone else worked had success extracting information from a
> > fipati
> > > class object?
> > >
> > > I realize this is porbably a simple "r-rookie" question, but
> i cannot
> > > find what I am looking for in other forums, my r book etc
> > >
> > > Great work on this package by the way, very helpful and much
> needed in
> > > the ecological community.
> > >
> > > Adam T. Ford
> > > Ph.D. Candidate
> > > Department of Zoology
> > > University of British Columbia
> > > Vancouver, B.C
> > >
> > > Canada
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > AniMov mailing list
> > > AniMov@faunalia.it <mailto:AniMov@faunalia.it>
<mailto:AniMov@faunalia.it <mailto:AniMov@faunalia.it>>
> <mailto:AniMov@faunalia.it <mailto:AniMov@faunalia.it>
<mailto:AniMov@faunalia.it <mailto:AniMov@faunalia.it>>>
> > > http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov
> >
> > --
> >
> > ~$ whoami
> > Mathieu Basille, Post-Doc
> >
> > ~$ locate
> > Laboratoire d'Écologie Comportementale et de Conservation de
> la Faune
> > + Centre d'Étude de la Forêt
> > Département de Biologie
> > Université Laval, Québec
> >
> > ~$ info
> > http://ase-research.org/basille
> >
> > ~$ fortune
> > ``If you can't win by reason, go for volume.''
> > Calvin, by Bill Watterson.
> >
> >
>
> --
>
> ~$ whoami
> Mathieu Basille, Post-Doc
>
> ~$ locate
> Laboratoire d'Écologie Comportementale et de Conservation de
la Faune
> + Centre d'Étude de la Forêt
> Département de Biologie
> Université Laval, Québec
>
> ~$ info
> http://ase-research.org/basille
>
> ~$ fortune
> ``If you can't win by reason, go for volume.''
> Calvin, by Bill Watterson.
>
>
--
~$ whoami
Mathieu Basille, Post-Doc
~$ locate
Laboratoire d'Écologie Comportementale et de Conservation de la Faune
+ Centre d'Étude de la Forêt
Département de Biologie
Université Laval, Québec
~$ info
http://ase-research.org/basille
~$ fortune
``If you can't win by reason, go for volume.''
Calvin, by Bill Watterson.
--
~$ whoami
Mathieu Basille, Post-Doc
~$ locate
Laboratoire d'Écologie Comportementale et de Conservation de la Faune
+ Centre d'Étude de la Forêt
Département de Biologie
Université Laval, Québec
~$ info
http://ase-research.org/basille
~$ fortune
``If you can't win by reason, go for volume.''
Calvin, by Bill Watterson.
_______________________________________________
AniMov mailing list
AniMov@faunalia.it
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov