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, > > > > From your helps o

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

2013-02-19 Thread Berend Hasselman
On 19-02-2013, at 09:55, Prakasit Singkateera wrote: > Hi everyone, > > From your helps of giving me several ideas, eventually I can solve the posted > problem. Here is the R code. It can be done by applying the uniroot.all to > the data frame together with the proper form of equation (slight

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

2013-02-19 Thread Prakasit Singkateera
Hi everyone, >From your helps of giving me several ideas, eventually I can solve the posted problem. Here is the R code. It can be done by applying the uniroot.all to the data frame together with the proper form of equation (slightly modification of the original equation). #Generate the sample da

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-18 Thread Rolf Turner
On 02/19/2013 09:44 AM, Berend Hasselman wrote: Rolf, Your attachments got through. But where is the function newt(…)? A --- dang! It's another item from my "personal miscellany package" which I'm so used to having around that I forgot that other people don't have it. Attached. Along

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

2013-02-18 Thread Berend Hasselman
Rolf, Your attachments got through. But where is the function newt(…) Berend On 18-02-2013, at 21:25, Rolf Turner wrote: > > Some (quite a few!) years ago I wrote myself a wee function called > compInt() ("compound interest") to do --- I think --- just what you require. > I have attached the

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

2013-02-18 Thread Rolf Turner
Some (quite a few!) years ago I wrote myself a wee function called compInt() ("compound interest") to do --- I think --- just what you require. I have attached the code for this function and a help file for it. If anyone else wants this code, and if the attachments don't get through the list,

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

2013-02-18 Thread Berend Hasselman
On 18-02-2013, at 10:34, Prakasit Singkateera wrote: > Hi all, > > Firstly, it is not a homework. I am working for a hotel booking company in > Thailand but I don't want to explain a complex equation and concept here so > I keep it simple and closely related to what I am trying to solve.I apolo

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

2013-02-18 Thread Prakasit Singkateera
Hi all, Firstly, it is not a homework. I am working for a hotel booking company in Thailand but I don't want to explain a complex equation and concept here so I keep it simple and closely related to what I am trying to solve.I apology if my question is not clear enough. I am new to R and previous

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

2013-02-17 Thread Bert Gunter
Homework? We don't do homework here. -- Bert On Sun, Feb 17, 2013 at 5:10 AM, Prakasit Singkateera wrote: > 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

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

2013-02-17 Thread arun
ay, February 17, 2013 8:10 AM Subject: [R] How to do a backward calculation for each record in a dataset 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

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

2013-02-17 Thread John Kane
ubject: [R] How to do a backward calculation for each record in a > dataset > > Hi Experts, > > I have a dataset of 3 columns: > > customer.name product cost > John Toothpaste 30 > Mike Toothpaste 45 > Peter Toothpaste 40 > > And

[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