Home R For Loop Set Up
Reply: 0

R For Loop Set Up

dz333
1#
dz333 Published in 2018-02-13 21:38:06Z

Need some help thinking of pseudocode for a school project I am working on. I have two data frames, one with a data frame of cars for sale and the other a data frame of current dealerships inventory. I essentially want to create a for loop that reads cars for sale and pairs them with multiple dealership lacking in their inventory.

I am more or less looking to see if anyone can help me conceptualize how to write a code for optimal purchases based off dealership preferences.How can I create a for loop that can allocate some of these cars for sale to different dealerships based off of needs? Hopefully this makes sense. Thanks!

for_sale=read.csv("for_sale.csv")
for_sale=subset(for_sale,select=c("Car","Price","Qty","Maker")
maker=c("Toyota","Honda","Lexus","Nissan","Mazda")
filtered_for_sale_preferences=for_sale[for_sale$Price<=60,000 &
                                       for_sale$Maker %in% maker,
                                       for_sale$Qty<=200]

dealership_orders=read.csv("dealership_orders.csv")


    here is filtered_for_sale_preferences
    Maker    Qty         Price
    1 Toyota 110         23000
    2  Honda  62         28000
    3  Mazda  81         25000
    4   Ford 163         35000
    5     GM 105         42000
    6  Buick  55         48000

Here is dealership orders/inventory

            Dealership Toyota Honda Mazda Target.Toyota Target.Honda Target.Mazda
          Albany     10    12     5            15           20           11
    2   New York      9     9     6            11           15            9
    3    Buffalo      2     2     8             6           17           13
    4   Syracuse      6    15     4            11           14           19
      Cash.to.Spend
    1   512,781.00 
    2   411,263.00 
   3   429,710.00 
   4   501,299.00 

basically want to allocate how many cars are needed at each dealership based off money to spend

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312023 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO