diff --git a/Pandas Series.pdf b/Pandas Series.pdf new file mode 100644 index 00000000000..78f59909391 Binary files /dev/null and b/Pandas Series.pdf differ diff --git a/README.md b/README.md index 7a8c502a4be..98d8e9351e8 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ really a list containing a function to 1. set the value of the vector 2. get the value of the vector 3. set the value of the mean -4. get the value of the mean +4. get the value of the mean diff --git a/cachematrix.R b/cachematrix.R index a50be65aa44..cb6e0db72cb 100644 --- a/cachematrix.R +++ b/cachematrix.R @@ -1,15 +1,37 @@ -## Put comments here that give an overall description of what your -## functions do +## makeCashMatrix creates vector which is list containing function +## what functions do is setting the value of the vector into "set" variable +## getting the value of the vector into "get" variable +## setting the value of the mean into "setmean" variable +## getting the value of the mean into "getmean" variable ## Write a short comment describing this function -makeCacheMatrix <- function(x = matrix()) { - +makeCacheMatrix <- function(listData = matrix()) { + mat <- NULL + set <- function(ld) { + listData <<- ld + mar <<- NULL + } + get <- function() listData + setmean <- function(mean) mat <<- mean + getmean <- function() mat + list(set = set, get = get, + setmean = setmean, + getmean = getmean) } +## cacheSolve function computes the inverse of the matrix. If the inverse +## has alreayd been calculated then the cachesolve should retrive the inverse +## from the cache. -## Write a short comment describing this function - -cacheSolve <- function(x, ...) { - ## Return a matrix that is the inverse of 'x' +cacheSolve <- function(listData, ...) { + mat <- listData$getmean() + if(!is.null(mat)) { + message("getting cached data") + return(mat) + } + data <- listData$get() + mat <- mean(data, ...) + listData$setmean(mat) + mat }