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
|