diff --git a/BeccaR16 b/BeccaR16 new file mode 100644 index 0000000..1870039 --- /dev/null +++ b/BeccaR16 @@ -0,0 +1,26 @@ +makeCacheMatrix <- function(x = matrix()) { + inv=NULL + set=function(y){ + x<<-y + inv<<-NULL +} +get=function() x +setinv = function(inverse) inv<<- inverse +getinv = function() inv +list(set=set, get=get, + setinv=setinv, + getinv=getinv) +} + +cacheSolve <- function(x, ...) { + inv=x$getinv() + if(!is.null(inv)){ + message("getting cached data") + return(inv) + } + mat.data=x$get() + inv=solve(mat.data, ...) + x$setinv(inv) + return(inv) +} +