The S&P 500 (^GSPC -0.21%) has never been higher; in fact, if you had invested in March 2009 -- the Great Recession's market bottom -- you'd be looking at a 150% return in just over four years. That might make you think stocks are too expensive, but if you look at a few individual companies in the S&P 500, that's not necessarily the case.

One way to measure whether a stock is "cheap" is by its price tag. That's not the best measure, though; it's highly influenced by how many shares a company has outstanding. A different metric to use is a company's price-to-earnings ratio. This tells you how much a stock is worth, relative to how much money its company made over the past year. Right now, the average S&P 500 stock trades for a P/E of 19.3. 

But even when we find companies with low P/E ratios, it doesn't necessarily mean they're a good investment -- these stocks could be trading cheaply for a reason. To dig deeper, let's investigate the five cheapest stocks in the S&P 500.

5. Yahoo! (NASDAQ: YHOO), P/E of 7.7
The Yahoo! homepage is the fourth-most visited website in both America and the world. Over the past three years, earnings have increased 135%. With numbers like these, you'd expect Yahoo! to be trading for higher, but there are two big concerns that have historically held the stock down.

The first is plain old-fashioned competition from the likes of Google. The second has to do with turnover in the executive suite. There have been five CEOs or interim CEOs for Yahoo! since co-founder Jerry Yang left in 2009.

However, the company's newest leader, Marissa Mayer, has been winning praise for finally giving the company a long-term vision. In fact, just this week, Yahoo! acquired Tumblr for $1.1 billion, giving Yahoo! access to a popular mobile platform with a younger generation of users.

4. Western Digital (WDC 0.90%), P/E of 7.5
Western Digital designs and manufactures data storage devices. The storage devices are used in PCs, Web servers, and network storage devices.

The exact types of devices Western designs are referred to as hard disk drives. Currently, they are in heavy demand to meet the ballooning data storage needs of just about every industry. Revenue and earnings have increased by about 75% over the past three years.

But investors need to beware. It is widely believed that solid-state drives will be the wave of the future -- primarily because they have no moving parts. Today, SSDs are too expensive for most customers, but as their prices come down, they could take away Western's core HDD business.

3. Valero Energy, P/E of 7.4
Valero is a major oil refiner and distributor based out of San Antonio, Texas. Beyond typical crude oil refining, Valero also has a hand in biofuels and ethanol.

The company's stock has almost doubled in the past year, yet it still trades for a cheap valuation. While Valero can be at the whim of volatile commodity prices, management seems to think there are good times ahead. The company recently bought 1,600 new rail cars to transport close to 30,000 barrels bitumen per day, and it's constructing a new refining facility in California.

If management is right, there could be a lot of upside to this oil stock.

2. Seagate Technology (STX) , P/E of 6.5
To understand Seagate and what it does, simply go back and read about Western Digital. These two companies combined control 90% of the world's HDD market.

One of the reasons Seagate trades for cheaper than Western is that its balance sheet isn't as healthy. Whereas Western has $4 billion in cash and $2 billion in long-term debt, Seagate has $1.9 billion in cash and $2.5 billion in debt. Though Seagate offers up a tempting 3.7% dividend yield, investors should consider the balance sheet and what SSDs will do to Seagate's core business in the future.

1. CF Industries (CF -0.41%), P/E of 6.4
CF is an Illinois-based company that makes fertilizers for the agricultural industry. Over the past few years, business has been booming, with earnings rising 275% in the past three years. This is largely because demand for the company's fertilizers has been in high demand, and input costs have been held down by record-low natural gas prices.

The big worry here is twofold. First, if natural gas prices rise -- which they've already begun doing -- input costs will rise. Second, if there's any dip in demand for CF's fertilizers, revenue will dip. Many of those concerns are already priced into the stock, but they're still worth considering before you buy in.