s-news
[Top] [All Lists]

Re: behavioural sequence

To: achaz@hermes.usherb.ca, s-news@lists.biostat.wustl.edu
Subject: Re: behavioural sequence
From: "Petr Pikal" <petr.pikal@precheza.cz>
Date: Tue, 25 Feb 2003 13:53:18 +0100
In-reply-to: <se5b6f43.079@dlwcmail.dlwc.nsw.gov.au>
Hi

On 25 Feb 2003 at 13:27, Hugh Jones wrote:

> The following works:
> 
> Achaz <- importData("c:\\temp\\test.txt")
> x <- rep(Achaz$Col1, Achaz$Col2)
> ifelse(x == "F", 1, 0)

or

(x=="F")*1

or in one line

rep(Achaz$Col1=="F", Achaz$Col2)*1

> 
> >>> Achaz von Hardenberg <achaz@hermes.usherb.ca> 02/24/03 08:40pm >>>
> Hi S-Plusers!
> 
> for a study in animal behaviour, I have a large number of files each
> with the following structure:
> 
> 1  F  5
> 2  A  4
> 3  F  3
> 4  S  5
> 5  F  7
> 6  A  6
> 7 ...  ...
> 
> The first column indicates the sequence, the second a behavioural
> pattern (F = Foraging, A= Alert, S= Sleep ...), the third is the time
> (in seconds) dedicated by the subject to each behaviour. I am looking
> for an S or R function to transform these files in a series of 1 and
> 0's with 1 for each second the animal was feeding and 0 for all other
> behaviours (A, S and others). The above sequence should therefore look
> like the following:
> 
> 111110000111000001111111000000
> 
> I think that this should (?) be quite straightforward to program, but
> I am a "0" in programming (and I guess also a bit lazy to start
> learning, also if I am aware I should!), so I am wondering if somebody
> outside there with more experience than me would be so kind to help me
> providing me with a code that would do it.
> 
> Thanks a lot!
> 
> achaz
> 
> 
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news
> 

CheersPetr Pikal
petr.pikal@precheza.cz
p.pik@volny.cz



<Prev in Thread] Current Thread [Next in Thread>