Write a function in R that receives two parameters. The first is data.fame or data.table, the second is a vector of integers. The function of the function is to return the rows of the first parameter whose serial number was in the vector in a new data.table or data.frame variable. If there is a larger number in the vector than the number of rows in the data table, then write a message for that number that the line was not included in the output.
I tried, but it's not a vector, and I don't know, how can I do this
get_vecrow = function(data, vecrow){
if (vecrow <= nrow(data) & vecrow > 0){
print(data[vecrow,])
}
else{
print("Row: ")
print(nrow(data))
}
}