Re: [R] Computing growth rate

2016-12-15 Thread Brijesh Mishra
Yes, Mr Hasselman. This works like charm now. I also realise where I was making an error. Now I have two very good options to choose from. Spoilt for choices... Many Many Thanks, Brijesh On Thu, Dec 15, 2016 at 7:53 PM, Berend Hasselman wrote: > >> On 15 Dec 2016, at 13:34, Brijesh Mishra wrot

Re: [R] Computing growth rate

2016-12-15 Thread Brijesh Mishra
R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Berend >> Hasselman >> Sent: Thursday, December 15, 2016 1:18 PM >> To: Brijesh Mishra >> Cc: r-help mailing list >> Subject: Re: [R] Computing growth rate >> >> >> > On 15 Dec 2016, at

Re: [R] Computing growth rate

2016-12-15 Thread Brijesh Mishra
Dear Mr. Barradas, Thanks a lot for pointing that. I tried that in a few steps- 1. when I evaluated d<-ddply(df1,"co_code1",transform, growth <- ifelse(diff(fyear1)==1, (exp(diff(log(df1$sales1)))-1)*100, NA)) I got the following, i.e., I was not getting the growth column automatically. co_code

Re: [R] Computing growth rate

2016-12-15 Thread Brijesh Mishra
Dear Mr Hasselman, I missed you mail, while I was typing my own mail as a reply to Mr. Barradas suggestion. In fact, I implemented your suggestion even before reading it. But, I have a concern that I have noted (though its only hypothetical- such a scenario is very unlikely to occur). Is there a w

Re: [R] Computing growth rate

2016-12-15 Thread Brijesh Mishra
This was ensured while using ddply()... On Thu, Dec 15, 2016 at 6:04 PM, Brijesh Mishra wrote: > Dear Mr Hasselman, > > I missed you mail, while I was typing my own mail as a reply to Mr. > Barradas suggestion. In fact, I implemented your suggestion even > before reading it. But, I have a concern

Re: [R] Computing growth rate

2016-12-15 Thread David Stevens
Berend - Unless you need the change in sales year by year, you might consider looking at each company's sales over the years and use regression or other type of trend analysis to get an overall trend... Or, if not, simply divide diff(sales) by diff(fyear1) for each company so at least you get t

Re: [R] Computing growth rate

2016-12-15 Thread Berend Hasselman
> On 15 Dec 2016, at 13:34, Brijesh Mishra wrote: > > Dear Mr Hasselman, > > I missed you mail, while I was typing my own mail as a reply to Mr. > Barradas suggestion. In fact, I implemented your suggestion even > before reading it. But, I have a concern that I have noted (though its > only hyp

Re: [R] Computing growth rate

2016-12-15 Thread PIKAL Petr
On Behalf Of Berend > Hasselman > Sent: Thursday, December 15, 2016 1:18 PM > To: Brijesh Mishra > Cc: r-help mailing list > Subject: Re: [R] Computing growth rate > > > > On 15 Dec 2016, at 04:40, Brijesh Mishra > wrote: > > > > Hi, > > > > I am try

Re: [R] Computing growth rate

2016-12-15 Thread Berend Hasselman
> On 15 Dec 2016, at 04:40, Brijesh Mishra wrote: > > Hi, > > I am trying to calculate growth rate (say, sales, though it is to be > computed for many variables) in a panel data set. Problem is that I > have missing data for many firms for many years. To put it simply, I > have created this sho

Re: [R] Computing growth rate

2016-12-15 Thread Rui Barradas
Hello, That is a very common mistake. if() accepts only one TRUE/FALSE, for a vectorized version you need ?ifelse. Something like the following (untested). growth <- ifelse(diff(fyear1)==1, (exp(diff(log(df1$sales1)))-1)*100, NA) Hope this helps, Rui Barradas Em 15-12-2016 03:40, Brijesh M