The variables declared inside a function are local to that function.
For e.g.:
foo <- function() {
m <- 2
}
foo()
m //gives the following error: Error: object 'bar' not found.
If you want to make m a global variable, you should do:
foo <- function() {
m <<- 2
}
foo()
m //In this case m is accessible from outside the function.