I'm supposed to make a function where you can insert a value into a vector, but if you attempt to place the value outside of the vector it gives the following output

This is what I have done so far which works for values within the dimensions of the vector, but I cannot figure out how to get the output from the image above
a <- 1:10
insert <- function(x, where, what) {
if(where<x+1) {
append(x,what,where - 1)}
else{
print("Warning message")
}
}