Re: [R] Generating Frequency Values

2013-11-26 Thread Burhan ul haq
Hi, A big thanks to everyone who replied. But special ones to Berend for pointing out my mistakes, that will really help me in future. Cheers ! On Tue, Nov 26, 2013 at 11:19 PM, Berend Hasselman wrote: > > On 26-11-2013, at 15:59, Burhan ul haq wrote: > > > Hi, > > > > My problem is as fol

Re: [R] Generating Frequency Values

2013-11-26 Thread Berend Hasselman
On 26-11-2013, at 15:59, Burhan ul haq wrote: > Hi, > > My problem is as follows: > > INPUT: > "Frequency" from one column and value of "Piglets" from another one > > OUTPUT: > Repeat this "Piglet" value as per the "Frequency" > i.e. > Piglet 1, Frequency 3, implies 1,1,1 > Piglet 7, Frequen

Re: [R] Generating Frequency Values

2013-11-26 Thread arun
Hi, Not sure whether this is what you wanted. df.1[rep(1:nrow(df.1),df.1[,2]),] A.K. On Tuesday, November 26, 2013 12:31 PM, Burhan ul haq wrote: Hi, My problem is as follows: INPUT: "Frequency" from one column and  value of "Piglets" from another one OUTPUT: Repeat this "Piglet" value as

Re: [R] Generating Frequency Values

2013-11-26 Thread Sarah Goslee
Hi, If I understand the question don't you simply want: > with(df.1, rep(Piglets, times=Frequency)) [1] 5 7 7 8 8 8 9 9 9 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 [26] 11 12 12 12 12 12 13 13 13 14 14 Sarah On Tue, Nov 26, 2013 at 9:59 AM, Burhan ul haq wrote: > Hi, > > My pr

[R] Generating Frequency Values

2013-11-26 Thread Burhan ul haq
Hi, My problem is as follows: INPUT: "Frequency" from one column and value of "Piglets" from another one OUTPUT: Repeat this "Piglet" value as per the "Frequency" i.e. Piglet 1, Frequency 3, implies 1,1,1 Piglet 7, Frequency 2, implies 7,7 SOLUTION: This is what I have tried so far: 1. A help