You must take either 2 cards or 0. You cannot take 1.
The game rules have extended text for the card, which generally trumps the text of the card itself:
Year of Plenty: If you play this card you may
immediately take any 2 resource cards from
the supply stacks. You may use these cards to
build in the same turn
They say you "may" take 2 resources, so the ability is optional, meaning you may also not take 2 resources (i.e. you could take 0). But it does not say "up to 2", so 1 resource is not an option.
There is a rules exception for how to handle resource shortages in production ("If the shortage of resource cards only affects a
single player, give that player as many of these resources as are
left in the supply, and any extras are lost"). However, under a strict reading of the rules, Year of Plenty is not "resource production", so this exception does not apply. Thus, if there is exactly one resource of any type left in the supply (an incredibly rare situation), you cannot take it with Year of Plenty.
Year of plenty probably ought to say "up to two", but that is not how it is worded in the rules, and changing that behavior would be a house rule.
Strategic note: using Year of Plenty to take resources that you aren't going to immediately spend is almost always a poor use of the card. The advantage of Year of Plenty is that it gives you 2 wildcard resources that aren't in your hand from the perspective of 7s and the robber. Playing Year of Plenty when you have 6 cards in hand and not immediately making a purchase or trade is a poor use of the card.