gt; On Behalf Of Jim Lemon
>> Sent: Friday, April 30, 2021 11:45 AM
>> To: e-mail ma015k3113 mailto:ma015k3...@blueyonder.co.uk>>; r-help mailing list
>> mailto:r-help@r-project.org>>
>> Subject: Re: [R] Help understanding loop behaviour
&
1009550 4 1 1
> > 191009550 4 1 2
> > 20 1009550 4 1 3
> > 211009550 4 4 4
> >
> > Cheers.
> > Petr
> >
> >> -Original Message-
> >> From: R-help
021 11:45 AM
To: e-mail ma015k3113 ; r-help mailing list
Subject: Re: [R] Help understanding loop behaviour
Hi email,
If you want what you described, try this:
xx<-read.table(text="COMPANY_NUMBER NUMBER_OF_YEARS
0070837 3
0070837 3
0070837 3
1000403 4
1000403 4
1000403 4
1000403 4
1
1
191009550 4 1 2
201009550 4 1 3
211009550 4 4 4
Cheers.
Petr
> -Original Message-
> From: R-help On Behalf Of Jim Lemon
> Sent: Friday, April 30, 2021 11:45 AM
> To: e-mail ma015k3113 ; r-help mailing list
>
&g
Hi email,
If you want what you described, try this:
xx<-read.table(text="COMPANY_NUMBER NUMBER_OF_YEARS
0070837 3
0070837 3
0070837 3
1000403 4
1000403 4
1000403 4
1000403 4
10029943 3
10029943 3
10029943 3
10037980 4
10037980 4
10037980 4
10037980 4
10057418 3
10057418 3
10057418
Hi
Your code is hardly readable as you used HTML formating (not recommended) so
I used another (split) approach.
Third column seems to be simple
#make list
lll <- split(as.factor(COMPANY_NUMBER), COMPANY_NUMBER)
#calculate sequences
as.numeric(unlist(lapply(lll, function(x) 1:length(x
shou
6 matches
Mail list logo