The first inch is bought to stop condensation. R-value is what you buy after that.
This page is about a pre-engineered steel building: a steel frame with steel purlins and girts, and the panel screwed straight to them, so there is no cavity at all and nothing between the inside air and the outside metal. A post-frame pole barn is wood framing under the same kind of skin and the arithmetic is different enough to be its own page, so it has one. Here the foam goes on the inside face of the skin, sprayed between the framing and, if the budget allows, over it.
Condensation is why foam wins this job rather than batts, and it is worth being exact about when it happens. Water forms where the panel is colder than the dew point of the air touching it. Two things get it there. On a clear, still night the roof radiates to the sky and falls several degrees below the outside air, which is the case everyone describes. The one that actually soaks most buildings is duller: an unsealed slab, bare ground, a vehicle brought in wet or an unvented propane heater puts moisture into the air, and it meets a cold panel on any winter day. Dry air against a cold panel does nothing at all, which is why sealing the floor matters as much as anything you spray.
The traditional answer is a faced fiberglass blanket laid over the purlins, and it fails in ways that have little to do with someone tearing it. It is punctured by the roof screws at installation, by design. It is crushed to almost no R-value where it is pinched between the purlin and the panel, which is itself part of why the cold lines appear along the framing. And air leaks at the laps. Closed cell foam sprayed onto the panel removes the air path and lifts the inside face of the assembly above the dew point, which is two mechanisms rather than one. It does that where it is continuous and actually stuck: a panel that is oily, rusty or loosely coated is where adhesion fails and the path comes back. How much vapor moves through after that is a number the maker publishes, and HandiFoam FR prints 0.9 perm at 1 in on its data sheet.
Then there is the size of it. A modest 30 by 40 ft building with 14 ft walls has about 3,000 sq ft of surface to cover. That is ten times a rim joist and three times a basement, and it is the number that decides whether you are buying kits or calling a contractor.