Hi
Is this
http://stackoverflow.com/questions/2150138/how-to-parse-milliseconds-in-r
what do you want?
Cheers
Petr
> -----Original Message-----
> From: Sidoti, Salvatore A. [mailto:sidoti.23 at buckeyemail.osu.edu]
> Sent: Sunday, April 24, 2016 1:48 AM
> To: PIKAL Petr <petr.pikal at precheza.cz>; William Dunlap
> <wdunlap at tibco.com>; Ista Zahn <istazahn at gmail.com>
> Subject: RE: [R] Splitting Numerical Vector Into Chunks
>
> There are terrific suggestions and I so appreciate everyone's help!
>
> Just one additional question: I also have some time data that accompanies
> this analysis. It is in the format h:m:s:00 where the last item is
hundreths of a
> second. I tried various things with the date and time functions in R, but I
have
> not found a way to convert the vetor into a workable time class.
>
> -----Original Message-----
> From: PIKAL Petr [mailto:petr.pikal at precheza.cz]
> Sent: Thursday, April 21, 2016 4:13 AM
> To: William Dunlap <wdunlap at tibco.com>; Ista Zahn <istazahn at
gmail.com>
> Cc: Sidoti, Salvatore A. <sidoti.23 at buckeyemail.osu.edu>
> Subject: RE: [R] Splitting Numerical Vector Into Chunks
>
> Hi
>
> Another aproach is to use diff to find steps.
>
> split(x, cumsum(abs(c(1,diff(x==0)))))
>
> Cheers
> Petr
>
>
> > -----Original Message-----
> > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of
> > William Dunlap via R-help
> > Sent: Wednesday, April 20, 2016 9:56 PM
> > To: Ista Zahn <istazahn at gmail.com>
> > Cc: r-help at r-project.org; Sidoti, Salvatore A.
> > <sidoti.23 at buckeyemail.osu.edu>
> > Subject: Re: [R] Splitting Numerical Vector Into Chunks
> >
> > > i <- seq_len(length(x)-1)
> > > split(x, cumsum(c(TRUE, (x[i]==0) != (x[i+1]==0))))
> > $`1`
> > [1] 0.144872972504 0.850797178400
> >
> > $`2`
> > [1] 0 0 0
> >
> > $`3`
> > [1] 0.199304859380 2.063609410700 0.939393760782 0.838781367540
> >
> > $`4`
> > [1] 0 0 0 0 0
> >
> > $`5`
> > [1] 0.374688091264 0.488423999452 0.783034615362 0.626990428900
> > 0.138188255307 2.324635712186
> >
> > $`6`
> > [1] 0 0 0 0 0 0 0
> >
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> > On Wed, Apr 20, 2016 at 12:49 PM, Ista Zahn <istazahn at
gmail.com> wrote:
> >
> > > Perhaps
> > >
> > > x <- split(x, x == 0)
> > >
> > > Best,
> > > Ista
> > >
> > > On Wed, Apr 20, 2016 at 9:40 AM, Sidoti, Salvatore A.
> > > <sidoti.23 at buckeyemail.osu.edu> wrote:
> > > > Greetings!
> > > >
> > > > I have several large data sets of animal movements. Their
pauses
> > > > (zero
> > > magnitude vectors) are of particular interest in addition to the
> > > speed distributions that precede the periods of rest. Here is an
> > > example of the kind of data I am interested in analyzing:
> > > >
> > > > x <-
> > >
abs(c(rnorm(2),replicate(3,0),rnorm(4),replicate(5,0),rnorm(6),repli
> > > ca
> > > te(7,0)))
> > > > length(x)
> > > >
> > > > This example has 27 elements with strings of zeroes (pauses)
> > > > situated
> > > among the speed values.
> > > > Is there a way to split the vector into zero and nonzero
chunks
> > > > and
> > > store them in a form where they can be analyzed? I have tried
> > > various forms of split() to no avail.
> > > >
> > > > Thank you!
> > > > Salvatore A. Sidoti
> > > >
> > > > ______________________________________________
> > > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and
more, see
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible
code.
> > >
> > > ______________________________________________
> > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more,
see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible
code.
> > >
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> > guide.html and provide commented, minimal, self-contained,
> > reproducible code.
>
> ________________________________
> Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou
> ur?eny pouze jeho adres?t?m.
> Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen?
> jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze
> sv?ho syst?mu.
> Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento
> email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
> Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou
> modifikacemi ?i zpo?d?n?m p?enosu e-mailu.
>
> V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
> - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en?
smlouvy, a
> to z jak?hokoliv d?vodu i bez uveden? d?vodu.
> - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout;
> Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany
> p??jemce s dodatkem ?i odchylkou.
> - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m
> dosa?en?m shody na v?ech jej?ch n?le?itostech.
> - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za
spole?nost
> ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo
> p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto
> emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich
> existence je adres?tovi ?i osob? j?m zastoupen? zn?m?.
>
> This e-mail and any documents attached to it may be confidential and are
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its
sender.
> Delete the contents of this e-mail with all attachments and its copies from
> your system.
> If you are not the intended recipient of this e-mail, you are not
authorized to
> use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible damage
caused
> by modifications of the e-mail or by delay with transfer of the email.
>
> In case that this e-mail forms part of business dealings:
> - the sender reserves the right to end negotiations about entering into a
> contract in any time, for any reason, and without stating any reasoning.
> - if the e-mail contains an offer, the recipient is entitled to immediately
> accept such offer; The sender of this e-mail (offer) excludes any
acceptance
> of the offer on the part of the recipient containing any amendment or
> variation.
> - the sender insists on that the respective contract is concluded only upon
an
> express mutual agreement on all its aspects.
> - the sender of this e-mail informs that he/she is not authorized to enter
into
> any contracts on behalf of the company except for cases in which he/she is
> expressly authorized to do so in writing, and such authorization or power
of
> attorney is submitted to the recipient or the person represented by the
> recipient, or the existence of such authorization is known to the recipient
of
> the person represented by the recipient.
________________________________
Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny
pouze jeho adres?t?m.
Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho
odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho
syst?mu.
Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email
jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i
zpo?d?n?m p?enosu e-mailu.
V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
- vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a
to z jak?hokoliv d?vodu i bez uveden? d?vodu.
- a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout;
Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce
s dodatkem ?i odchylkou.
- trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m
dosa?en?m shody na v?ech jej?ch n?le?itostech.
- odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost
??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn?
pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn?
osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi
?i osob? j?m zastoupen? zn?m?.
This e-mail and any documents attached to it may be confidential and are
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender.
Delete the contents of this e-mail with all attachments and its copies from your
system.
If you are not the intended recipient of this e-mail, you are not authorized to
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by
modifications of the e-mail or by delay with transfer of the email.
In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately
accept such offer; The sender of this e-mail (offer) excludes any acceptance of
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into
any contracts on behalf of the company except for cases in which he/she is
expressly authorized to do so in writing, and such authorization or power of
attorney is submitted to the recipient or the person represented by the
recipient, or the existence of such authorization is known to the recipient of
the person represented by the recipient.