Shares of retail giants CVS Health Corp. (NYSE:CVS) and Wal-Mart Stores, Inc. (NYSE:WMT) have moved in opposite directions this year. While the pharmacy stock has given up about 19% this year, the superstore icon has rewarded investors with a 17% gain.

Image source: Getty Images.

The divergence has plenty scratching their heads. In recent quarters, Wal-Mart has slowed new store openings, but CVS Health's retail footprint ballooned this year as it rebranded over 1,600 pharmacies within Target stores nationwide.

Clearly, there's more at play than the simple expansion of physical locations, and investors are right to wonder which stock is the better buy right now. Let's see how the two stack up to determine which comes out ahead.

Tough pill to swallow

CVS Health investors have watched earnings per share grow a whopping 189% over the past decade, but a recent warning might have their physicians writing new anti-anxiety scripts. During its third-quarter earnings report, management lowered 2016's adjusted earnings guidance range slightly to between $5.77 and $5.83 per share. Guidance provided for 2017 was downright disturbing, as it suggests the bottom line could flatten out with adjusted earnings in the $5.77- to $5.93-per-share range.

The guidance revision stems from a projected loss of more than 40 million retail prescriptions next year. This summer, Walgreens Boots Alliance displayed presidential dealmaking skills by steering scores of Blue Cross Blue Shield and Tricare network members away from CVS pharmacies and through its own doors.

While the guidance for next year is certainly upsetting, it's important to note that CVS is much more than a simple pharmacy chain. The company runs America's second-largest pharmacy benefit manager, a service that end payers increasingly rely on to manage prescription drug costs. In fact, its pharmacy services segment contributed about 45% of total operating profit recorded in the first nine months of the year, up from about 39% in 2010.

Image source: Getty Images.

In addition to pharmacy services, CVS Health will ride the trend toward increasing reliance on long-term care facilities as the number of Americans over age 65 skyrockets. Last year it acquired Omnicare, a leading service provider for such facilities, and CVS is still integrating Omnicare's operations.

Revenue sources a-changin'?

While CVS Health braces for an abrupt slowdown, growth at Wal-Mart has ticked up just 2% in the past five years. A focus adjustment, from the enormous Supercenters that drove growth for decades to little Express stores, basically flopped. Midsized Neighborhood Markets have also been less than impressive.

But now, Wal-Mart's e-commerce efforts are beginning to look like as if they could pave the way forward for the struggling company. This summer's $3.3 billion purchase of may have been the jump-start its online presence needed. Third-quarter e-commerce sales grew 20.6% over the previous year period, which was an impressive acceleration over a year-on-year increase of just 7% in the first quarter.

If its online presence is going to help the company grow, it will need to continue putting up double-digit growth for quite some time. Third-quarter e-commerce sales made their largest contribution ever to the U.S. segment, but at just 0.5% of the total, it's like towing a shipping container with a motorcycle.

Running the numbers

CVS Health's stock is slightly more expensive than Wal-Mart's with respect to trailing earnings. Looking forward, though, it's significantly cheaper at just 13.7 times this year's estimates.

CVS PE Ratio (TTM) Chart

CVS PE Ratio (TTM) data by YCharts

With respect to dividends, CVS Health can't hold a candle to Wal-Mart's 43-year history of consecutive raises, but a track record of 13 years of higher payments is nothing to sneeze at, either. In fact, I imagine income investors look past its adolescent distribution to focus on the blazing pace at which it's been raising payments.

CVS Dividend Chart

CVS Dividend data by YCharts

Over the past five years, CVS Health has boosted its payout at a stunning 32% annual rate, and during the past 12 months, it has used just 34.8% of profits to make payments to its happy shareholders. In stark contrast, Wal-Mart has barely nudged its payout upward over the past few years but needs to divert a larger proportion of profits to do so.

The 2.8% yield Wal-Mart Stores shares offer at recent prices is better than the 2.1% you'd see from CVS Health, but I think you can reasonably expect a better yield on your original investment before too long with the healthcare stock. After all, the retail behemoth's avenue to growth is still blurry, but the pharmacy chain's is well defined. This is why I'm calling CVS Health a much better buy right now.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.