It's no secret that some areas of the country are more expensive to live in than others. Or that salaries, housing costs and taxes can vary.

To help figure out how far your money will go based on where you live, new research looks at the amount needed to cover necessities — housing, health care, groceries, utilities and transportation — in the 50 largest U.S. cities, broken down by whether you're a renter or a homeowner.

Applying government and industry data, the GOBankingRates cost-of-living study also uses the "50-30-20 rule" to assume that to live comfortably, you'd need those necessities to eat up just 50% of your budget, 30% would go to discretionary spending and 20% to savings.

In other words, if you want a comfortable lifestyle, you'd need income that's double the amount that goes toward basic living expenses.

For many households, covering those costs is challenging. In some spots, the pretax median household income — half fall above, half below — doesn't even cover that necessities tab, the data shows. Or, it can depend on whether you pay rent or a mortgage.

In other cities, better incomes and lower living expenses paint a much better picture regardless of how you pay for housing.

The costliest place, as ranked by the study, is San Francisco, where median household income is $96,265 annually.

Despite that being nearly $35,000 above the national median of $61,372, it's still about $19,000 shy of the $115,000 needed to cover necessities there if you're a homeowner.

More from Personal Finance:

3 reasons why your 2018 tax season is painful

Here's your retirement savings gap, based on your age

Banks nickeled-and-dimed college students for millions in fees

That group would need roughly $230,000 to live comfortably — nearly $134,000 higher than the city's median income.

Renters in San Francisco are in a better spot and even have a cushion: The total needed to cover necessities is $82,000 — about $14,000 below the median income (again, $96,265). The live-comfortably mark if you pay a landlord is $164,000.

In Miami, renters pay more for the basics than homeowners, although neither group fares well, the study shows.

To pay for necessities there if you rent, you need about $54,800. That's $20,800 more than the median household income of $34,000. Homeowners need $52,500 to cover the basics, which is $18,500 higher than the median income.

To live comfortably, renters would need about $109,600 in income; homeowners, $105,000.

It's easier to live large in Virginia Beach, Virginia, where median income is $70,500. Like Miami, though, paying a landlord there comes with a higher cost of living.

Renters in Virginia Beach spend $43,700 on the basics, giving the average household a cushion of $26,800. For homeowners, who spend about $41,600 on necessities, the surplus is about $28,900.

Living comfortably there also is less out of reach. Homeowners would need about $83,200, which is $12,700 above the median income. For renters, the average household falls short of the $87,400 by about $16,900.

To check expenses in other big cities, the full report is here.

Subscribe to CNBC on YouTube.