12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

If you frequently work with tables in Excel, you should definitely explore thepackages plyr and reshape2 that are available on CRAN at http://cran.rproject.org/web/packages/plyr/and http://cran.rproject.org/web/packages/reshape2/,respectively. These packages provide anumber of functions for common data manipulation problems.Using the Goal Seek and SolverOne very powerful feature of Excel is that it has a very easy-to-use solver thatallows you to find minimum or maximum values for functions given someconstraints.A very large body of mathematics aims to solve optimization problems of allkinds. In R, the optimize() function provides one fairly simple mechanism foroptimizing functions.Imagine you’re the sales director of a company and you need to set the bestprice for your product. In other words, find the price of a product that maximizesrevenue.In economics, a simple model of pricing states that people buy less of a givenproduct when the price increases. Here’s a very simple function that has thisbehavior:> sales revenue par(mfrow=c(1, 2))> curve(sales, from=50, to=150, xname=”price”, ylab=”Sales”, main=”Sales”)> curve(revenue, from=50, to=150, xname=”price”, ylab=”Revenue”,main=”Revenue”)> par(mfrow=c(1, 1))

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!