If you mean, make the code react to a user input for number of variables, then all you need to do is create an input widget for the user to select the number of variables. Either a sliderInput or numericInput or selectInput will do.
Then, you won't need m <- reactive({1:5}). You can just have your loop reference the input like this: for(i in 1:input$number){ your code }.
As for making the variables accessible by other functions, you should be able to use the envir argument of assign() to scope it to a different environment that's more accessible. Try envir = globalnenv().