Match a regular expression that starts at the beginning
^ or after a space
[[:space:]] and is followed by an alphabetical character
[[:alpha:]]. Globally (the g in gsub) replace all such occurrences with the matched beginning or space and the upper-case version of the matched alphabetical character,
\\1\\U\\2. This has to be done with perl-style regular expression matching.
gsub("(^|[[:space:]])([[:alpha:]])", "\\1\\U\\2", name, perl=TRUE) #  "Zip Code" "State" "Final Count"
In a little more detail for the replacement argument to
\\1 says 'use the part of
x matching the first sub-expression', i.e., the part of
\\2 says use the part of
x matching the second sub-expression
\\U is syntax enabled by using
perl=TRUE, and means to make the next character Upper-case. So for "Zip code",
\\1 is "Zip",
\\2 is "code",
\\U\\2 is "Code", and
\\1\\U\\2 is "Zip Code".
?regexp page is helpful for understanding regular expressions,
?gsub for putting things together.