Prakasit Singkateera
2013-Feb-17 13:10 UTC
[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 cost whereby cost = 3.40 + (1.20 * no.of.orders^2) I want to do a backward calculation for each records (each customer) to find his no.of.orders and create a new column named "no.of.orders" in that dataset but I don't know how to do. Please help me. Thank you everyone, Prakasit [[alternative HTML version deleted]]
John Kane
2013-Feb-17 17:08 UTC
[R] How to do a backward calculation for each record in a dataset
This sounds a bit too much like homework. And in any case https://github.com/hadley/devtools/wiki/Reproducibility John Kane Kingston ON Canada> -----Original Message----- > From: asltjoey.rsoft at gmail.com > Sent: Sun, 17 Feb 2013 20:10:13 +0700 > To: r-help at r-project.org > 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 cost whereby > > cost = 3.40 + (1.20 * no.of.orders^2) > > I want to do a backward calculation for each records (each customer) to > find his no.of.orders and create a new column named "no.of.orders" in > that > dataset but I don't know how to do. > > Please help me. > > Thank you everyone, > Prakasit > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
arun
2013-Feb-17 17:11 UTC
[R] How to do a backward calculation for each record in a dataset
Hi, I am? not sure I understand it correctly. dat1<-read.table(text=" customer.name??? product??? cost John??? Toothpaste??? 30 Mike??? Toothpaste??? 45 Peter??? Toothpaste??? 40 ",sep="",header=TRUE,stringsAsFactors=FALSE) ?dat1$no.of.orders<-? sqrt((dat1$cost-3.40)/1.20) ?dat1 #? customer.name??? product cost no.of.orders #1????????? John Toothpaste?? 30???? 4.708149 #2????????? Mike Toothpaste?? 45???? 5.887841 #3???????? Peter Toothpaste?? 40???? 5.522681 A.K. ----- Original Message ----- From: Prakasit Singkateera <asltjoey.rsoft at gmail.com> To: r-help at r-project.org Cc: Sent: Sunday, 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 cost whereby cost = 3.40 + (1.20 * no.of.orders^2) I want to do a backward calculation for each records (each customer) to find his no.of.orders and create a new column named "no.of.orders" in that dataset but I don't know how to do. Please help me. Thank you everyone, Prakasit ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Bert Gunter
2013-Feb-17 18:18 UTC
[R] How to do a backward calculation for each record in a dataset
Homework? We don't do homework here. -- Bert On Sun, Feb 17, 2013 at 5:10 AM, Prakasit Singkateera <asltjoey.rsoft at gmail.com> 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 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 customer) to > find his no.of.orders and create a new column named "no.of.orders" in that > dataset but I don't know how to do. > > Please help me. > > Thank you everyone, > Prakasit > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm