There are R packages that will help you do this, (look up simplex method implementations). Even if you didn't want to load a package, you could learn from the code in those packages.
Is this a homework question?
Do be aware of our homework policy here FAQ: Homework Policy
And we made a short guide for helping folks pose their R-coding questions here.