Hello All,

I'm new to this mailing list, so please let me know if I've committed any
posting faux-pas.

I'm working on an assignment for my Coursera course; please see my code
below in which I have tried to write two functions--to perform the task of
matrix inversion and then caching that data.  My code is below:

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

        i <- NULL

        set <- function(y) {

                x <<- y

                i <<- NULL

        }

        get <- function() x

        setinverse <- function(solve) i <<- solve

        getinverse <- function() i

        list(set = set, get = get, setinverse = setinverse,

             getinverse = getinverse)

}



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

        i <- x$getinverse()

        if(!is.null(i)) {

                message("getting cached data")

                return(i)

        }

        data <- i$get()

        i <- solve(data, ...)

        x$setinverse(i)

        i

}

After I create a new matrix, x, and try to run cacheSolve(x), I receive
this error: "attempt to apply non-function."

I'm new to using the <<- operator, so I'm not sure if that's where my error
is?

Can anyone suggest how I can go about debugging the above code?

Thanks very much,

Sam Colon
Coursera Student

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to