Hi,
I'm making a database for my company, and I would like to automate some
tasks.
One of the tasks that is demanding a lot of time is making up the task schedule.
I'm wondering if it's possible to automate this, and how this can be
done.
As the database is made up in postgresql, I can access my data from R.
Below you will find some example data.
Product: Which product?
Batch: Which batch of the product?
Date in: Date when the samples arrive
Date out: Deadline date when the samples should be analysed
Analysis: Which method should be used?
Startup cost: cost to setup the analysis
Sup cost: supplementary cost per sample after the analysis has been setuped.
So if you take a look at the data, Product A, batch 1 and 2 can be analysed
together with product B batch 1 and 2 for analysis A, to reduce the costs
(startup cost counts only once). Product A batch 3 arrives too late to go for
one time analysis A.
Any ideas about how this can be done?
Thanks for your time
Bart
Sample data:
dat <- structure(list(Product = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L), .Label = c("A", "B"), class =
"factor"),
Batch = c(1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 2L),
Date.in = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 1L,
2L, 2L, 2L), .Label = c("10/05/09", "11/05/09",
"18/05/2009"
), class = "factor"), Date.out = structure(c(1L, 1L, 2L,
2L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("15/05/09",
"16/05/09", "23/05/09"), class = "factor"),
Analysis = structure(c(1L,
2L, 1L, 2L, 1L, 2L, 1L, 3L, 4L, 1L, 3L, 4L), .Label = c("A",
"B", "C", "D"), class = "factor"),
Startup_cost = c(100L,
120L, 100L, 120L, 100L, 120L, 100L, 50L, 60L, 100L, 50L,
60L), Sup_cost = c(10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L)), .Names = c("Product", "Batch",
"Date.in",
"Date.out", "Analysis", "Startup_cost",
"Sup_cost"), class = "data.frame", row.names = c(NA,
-12L))
[[alternative HTML version deleted]]