How to make smaller categories with factor character variables
While you are trying this in R, I have a solution in Pyhton. You could use a similar logic in R:

# Say this is your list:
countries = ['IN', 'DE', 'US', 'UK']

# Create a list of countries in different continents like this:
asia = ['IN', 'NP']
america = ['US', 'CD']
europe = ['DE', 'UK', 'FR']

# You can then map your list with these values using a definition:
for i in range(len(countries)):
    if countries[i] in asia:
        countries[i] = 'Asia'
    elif countries[i] in america:
        countries[i] = 'America'
    elif countries[i] in europe:
        countries[i] = 'Europe'
    else:
        countries[i] = 'Others'

# Now check your list
countries
['Asia', 'Europe', 'America', 'Europe']


Once this list is ready, you could create your boxplot.

Hope this helps.