title: R 3.1.3 'Error attempt to apply non-function' within own designed function to cache an inverse matrix
body: <p>Hi I am writing a function to cache an inverse matrix to minimise computation time.</p>
  
  <p>I expect that the function will output an inverse matrix however I get an error that says I am attempting to apply a non-function.</p>
  
  <p>The first piece of code creates a function to set up data for the second function. This, in theory takes at matrix inverts it and stores it.</p>
  
  <pre><code>makeCacheMatrix &lt;- function(x = matrix()) {
      m &lt;- NULL
      set &lt;- function (y) {
        x &lt;&lt;- y
        m &lt;&lt;- NULL
      }
      get &lt;-function() x
      setmatrix &lt;- function(solve) m&lt;&lt;- solve
      getmatrix &lt;- function() m
      list (set=set, get=get, setmatrix=setmatrix, getmatrix=getmatrix)
  }
  </code></pre>
  
  <p>I expect no outout at this stage  as I said it just sets up the data. below <code>casheSolve</code> takes a matrix and checks it against the data set up in <code>makeCacheMatrix</code> </p>
  
  <pre><code>cacheSolve &lt;- function(x, ...) {
    m &lt;- x$getmarix()
    if(!is.null(m)){
      message("getting cached data")
      return(m)
    }
    data &lt;- x$get()
    m &lt;- solve(data,...)
    x$setmatrix(m)
    m
    ## Return a matrix that is the inverse of 'x'
  }
  </code></pre>
  
  <p>This all enters fine with no errors in my log. I then go to test it and I get an error. </p>
  
  <pre><code>n &lt;- matrix(1:4,2,2)
  h &lt;- makeCacheMatrix(n)
  cacheSolve(h)
  </code></pre>
  
  <p>Error in cacheSolve(h) : attempt to apply non-function</p>
  
  <p>I have a similar function for saving the mean of a vector and that runs error free I am not sure whether I have missed a step in converting it from considering vectors to considering matrixies. </p>
  
  <p>viewing that code may also help to give a better gist so I have included it below</p>
  
  <pre><code>makeVector &lt;- function(x = numeric()) {
    m &lt;- NULL
    set &lt;- function(y) {
      x &lt;&lt;- y
      m &lt;&lt;- NULL
    }
    get &lt;- function() x
    setmean &lt;- function(mean) m &lt;&lt;- mean
    getmean &lt;- function() m
    list(set = set, get = get,
         setmean = setmean,
         getmean = getmean)
  }
  
  cachemean &lt;- function(x, ...) {
    m &lt;- x$getmean()
    if(!is.null(m)) {
      message("getting cached data")
      return(m)
    }
    data &lt;- x$get()
    m &lt;- mean(data, ...)
    x$setmean(m)
    m
  }
  
  z &lt;- makeVector()
  z$set(1:4)
  cachemean(z) 
  </code></pre>