I'm looking to take 4 vectors (Year, Type, Update, Percent) and define all possible combinations (modscombo) and then apply these combinations of values across a master vector of values (location) as a multiplier.
Example:
year <- c("Pre-95", "95-01", "02-13")
type <- c("A","B","C")
update <- c("Pre-08", "08-13", "14-18")
percent <- c(1,2,3)
modifiers <- data.frame(year, type, update, percent)
modscombo <- expand.grid(modifiers)
...once I have each combination of modifiers... I would like to apply each modifier to the each of the location values below:
area <- c(12345,67890,01234,11111,22222,33333,44444,55555,66666,77777,88888,99999)
location <- data.frame(area)
I am able to generate all combinations from the lists via the expand.grid
code but I am then looking to apply each result across the large vector of location values. What would be the best method of completing this task? Some sort of matrix?
Any help would be great! Thank you!
*####### To expand, I was requested to build a basic pricing rate table (that will sit in the background of an application). Each individual variable in the 4 vectors (year, type, update, percent) is a factor with a weight/multiplier. Each vector is in order from worst to best rating. So the combination from the 4 vectors with year of "Pre-95", type "A", update "Pre-08", and percent "1" would be the worst possible rating (I plan on adding actual values/ratings later on).
There will be 300 combinations of possible ratings and about ~30,000 locations overall. The end goal would be to apply all 300 combinations of ratings/multipliers to each of the location values in the location vector. Each location has its own individual rating, so each location multiplied by each of the 300 combinations will results in a unique result. ########