[R] How to do a backward calculation for each record in a dataset

2013-02-17 Thread Prakasit Singkateera
Hi Experts, I have a dataset of 3 columns: customer.name product cost John Toothpaste 30 Mike Toothpaste 45 Peter Toothpaste 40 And I have a function of cost whereby cost = 3.40 + (1.20 * no.of.orders^2) I want to do a backward calculation for each records (each

Re: [R] How to do a backward calculation for each record in a dataset

2013-02-18 Thread Prakasit Singkateera
e calculate the total_number_of_payments for you. Thanks arun. But that was you solved the original equation and put it as a new formula to R to calculate the result which is easy as long as the original equation is not complex. Thanks you, Prakasit Singkateera On Mon, Feb 18, 2013 at 1:18 AM, Ber

Re: [R] How to do a backward calculation for each record in a dataset

2013-02-18 Thread Prakasit Singkateera
Hi Berend, Thank you for your information. However, I am still not clear on the Rpmt function please elaborate more about - What is the purpose of Rpmt function? Why do you subtract pmt(xrate,x,xpv) from xpmt? / What is the meaning of xpmt ? - And what is the purpose of doing Rpmt(xpv/xpmt/2,xra

Re: [R] How to do a backward calculation for each record in a dataset

2013-02-19 Thread Prakasit Singkateera
)) mysolution #Remove the redundant mydata as mysolution it is an extended version of mydata rm(mydata) #Note uniroot.all can be used for both linear (e.g.orders^1) and non-linear (e.g.orders^2) equations. Thank you, Prakasit Singkateera [[alternative HTML version deleted]] _

Re: [R] How to do a backward calculation for each record in a dataset

2013-02-19 Thread Prakasit Singkateera
Hi Berend, Your method is really much better. Thank you very much. (Yes I also forgot to add the $root at the end.) Best, Prakasit On Tue, Feb 19, 2013 at 10:51 PM, Berend Hasselman wrote: > > On 19-02-2013, at 09:55, Prakasit Singkateera > wrote: > > > Hi everyone, >