"Replacement has 1 row, data has 0" when creating a function, that returns values from data frame.

The standard way to ask this type of question in this group is to create a reproducible example.
Please have a look at that. When you add to your code (a small version of) your data it becomes much easier for us to see what goes wrong. If data is confidential just make it up with fake data as long as the structure of the data is the same.

Looking only at your function:
the error indicates the line
aapo[,1] <- NA
If there are no rows in aapo (because the region is not in the table) this line will fail.
So first check if the number of rows is zero:

aapo <- subset(df, Alue == region)
if (nrow(aapo) == 0) return("Region does not exist")
...