#We're going to create two functions:
#First, makeCacheMatrix(), which function creates a special "matrix" object
#that can cache its inverse.
#Then, cacheSolve(), which function computes the inverse of the special
#"matrix" returned by makeCacheMatrix above. If the inverse has already
#been calculated (and the matrix has not changed), then cacheSolve will
#retrieve said inverse from the cache.

#So we'll start with makeCacheMatrix():

makeCacheMatrix <- function(x = matrix()) {

  y <- NULL               #This will be used by cacheSolve()
                          #to show whether or not the inverse matrix
                          #operation has been done yet.

  getMatrix <- function() x         #pulls original matrix

  setInverse <- function(inverse)   #called by cache function upon
                                    #its first run
                {y<<- inverse}      #...and stores the inverse matrix to
                                    #y via superassignment


  returnInverse <- function() y     #and this returns the cached inverse
                                    #matrix if cacheSolve() is run again.

  list(getMatrix=getMatrix, setInverse=setInverse, returnInverse=returnInverse)
}
# Then we'll create the function cacheSolve() to check whether the inverse
# matrix has been created, and if not, to do so and store it as a variable.

cacheSolve <- function(x, ...) {

  y<- x$returnInverse()             #here, we check the value of y to see
                                    #if it has been assigned a value yet

  if(!is.null(y)) {                 #if m /= NULL, then the inverse function
                                    #has already been run, and we can pull
                                    #the cached inverse matrix.
    message("Retrieving cached data...")  #first, we print a 'hang on!'
                                          #message to the console;
    return(y)                             #and after printing the cached
                                          #inverse matrix, end the function.
  }

  data <- x$getMatrix()                #if m==NULL, then we need to pull the
                                       #original matrix value;

  y <- solve(data, ...)                #then we invert the matrix;

  x$setInverse(y)
  y                                    #and print the inverse matrix.

}