Here's an example to get you started, keep in mind that the data in the matrix is somewhat defined by its dimensions which is why I've told it to create a matrix of all NA.
matrix_maker <- function() {
x <- as.integer(readline("Number of rows: "))
y <- as.integer(readline("Number of cols: "))
matrix(data = NA,
nrow = x,
ncol = y)
}
matrix_maker()
This will prompt the user to input the number of rows and columns in the console of the new matrix.