Republicans have been the party of the rich and Democrats the party of the poor for about as long as political scientists have collected data on American elections.

That might not be quite so true anymore, at least among white voters.

Hillary Clinton won the nation’s richest and most exclusive neighborhoods by a wide margin in the 2016 presidential election, according to an Upshot analysis of election results from Ryne Rohla of Washington State University and census data. And Donald J. Trump fared significantly better than Mitt Romney in the white districts that were the least affluent and least educated.

How the vote in white neighborhoods changed, by income

Representing precincts where at least 90 percent of the voting-age population is white.

Whether Democrats can continue to excel among the most affluent voters is one of the biggest questions heading into the midterm elections. Democrats are hoping to compete in many well-educated, affluent districts where Mr. Trump struggled but where voters have traditionally voted Republican and continued to do so down-ballot in 2016.

In special and general elections in the last year and a half, Democrats have generally succeeded in matching Mrs. Clinton’s tallies in the areas where she most outperformed prior Democrats, like in Georgia’s Sixth Congressional District or in Northern Virginia. But they typically haven’t outperformed Mrs. Clinton by much, and in some cases not at all -- and those elections didn’t have a Republican incumbent on the ballot.

The precinct-level data, which is far more granular than the county-level data available immediately after the election, complements a growing body of evidence that is forcing a re-evaluation of some of the initial views of the 2016 presidential election. It appears that Mrs. Clinton succeeded at winning over many rich and well-educated Republicans, perhaps by an even wider margin than pre-election polls implied, just as Mr. Trump made big gains in the poorest white communities compared with Mr. Romney. But there were more not-so-affluent white voters without a college degree in the battleground states, and Mr. Trump’s success with them was enough to give him the edge in the Electoral College.

It has been common in recent decades to caricature Democrats as dominated by the liberal elite, but Republicans continued to win among the wealthiest voters until very recently. Even in 2012, Barack Obama did not perform better in affluent white areas than he did in less affluent white areas. Almost exclusively white communities favored Mitt Romney by about 20 points, regardless of income.

But these same communities shifted decisively along lines of income and education.

Those in poorer precincts shifted to the right, and those in wealthier precincts shifted substantially to the left. Similarly, Mrs. Clinton’s support among well-educated white precincts surged, while it collapsed in white precincts that were the least educated.

How the vote in white neighborhoods changed, by education

Representing precincts where at least 90 percent of the voting-age population is white.

The effect is strikingly linear, with seemingly every additional notch of income or education yielding more Democratic support and a bigger Democratic gain over 2012.

A more advanced statistical analysis shows that education was the dominant driver of the shift, which is to say that higher-income precincts moved toward Mrs. Clinton mainly because they’re generally better educated.

Neither the exit polls nor county-level data are particularly useful tools for analyzing voting by income, in part because the highest-income voters are often concentrated in communities too small to dominate a county or not numerous enough to be included in an exit poll of only a handful of sample precincts nationwide.

The more granular precinct data tells a somewhat different story. And so does much of the national survey data, though not all of it. In general, the surveys are limited by small sample size among the richest voters. (One prominent political science survey, for instance, had just 84 respondents making more than $250,000.)

The precinct data and much of the survey data indicate that Mrs. Clinton’s effort to lure well-educated and rich Republicans was largely a success. She won college-educated white voters by a wide and maybe even a double-digit margin in non-exit poll survey data, which would exceed her standing in pre-election polls.

The precinct data implies that Mrs. Clinton’s gains were concentrated among the wealthiest voters; she carried precincts where the median income was over $250,000 by a 27-point margin, and improved by 39 points over Mr. Obama’s performance.

It should be noted that the results in homogeneous precincts don’t necessarily offer a clear view of how an overall group voted. It is possible, for instance, that affluent white voters in diverse precincts voted even more for Mrs. Clinton.

Likewise, it’s possible that affluent voters in less affluent precincts voted overwhelmingly for Mr. Trump,

But survey data tends to confirm that Mrs. Clinton excelled among these voters, as the precinct data suggests.

The Cooperative Congressional Election Study, a large survey conducted by political scientists, found that Mrs. Clinton won voters with a family income of more than $250,000 by a 20-point margin, with a relatively large sample of 1,310 respondents. Pre-election polls in 2016, which may counterintuitively be a better measure of the electorate than the deeply flawed exit polls, also showed Mrs. Clinton with a commanding lead among the most affluent voters. Exit polling merely showed a tie (at 46 percent each) among voters who made more than $250,000 per year.