Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rdpeng/ProgrammingAssignment2
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: willie14/ProgrammingAssignment2
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Dec 21, 2014

  1. Create Willies Prog 2

    #WE ASSUME THAT var Y is already in our environment 
    #first ,matrix is cached to zero ,
    #through solve () is defined how the inverse of the matrix defined (matrix should be a square one.)
    
    makeCacheMatrix <- function(x = matrix(data = as.vector(y),nrow= nummeric(a),ncol=nummeric(b)  ) ) {
      if(dim(x)<=a*b){
           matrixcache<- NULL
            set <- function(y) {
                    x <<- y
                    matrixcache<<- NULL
            }
            get <- function() x
            setinv <- function(solve) inv <<- solve(x)
            getinv <- function() inv
            list(set = set, get = get,
                 setinv = setinv,
                 getinv = getinv)
           # inverse saved first in this list 
    }
      
      
    }
    
    ## solving or inversing the cache matrix that u had just made
    
    cacheSolve <- function(x) {
            inv <- x$getinv()
            if(!is.null det((inv)) {
                    message("getting cached data")#make sure the det ist       not 0 4 inverse 
                    return(inv)
            }
            data <- x$get()
           inv <- inv(data)
            x$setinv(inv)
            inv
    
            ## Return a matrix that is the inverse of 'x'
    }
    
    
    ```
    
    
    
    
    
    
    
    
    
    ```{r}
    makeVector <- function(x = numeric()) {
            m <- NULL
            set <- function(y) {
                    x <<- y
                    m <<- NULL
            }
            get <- function() x
            setmean <- function(mean) m <<- mean
            getmean <- function() m
            list(set = set, get = get,
                 setmean = setmean,
                 getmean = getmean)
    }
    
    ```
    
    You can also embed plots, for example:
    
    ```{r, echo=FALSE}
    #The following function calculates the mean of the special "vector" created with the above function. However, it first checks to see if the mean has already been calculated. If so, it gets the mean from the cache and skips the computation. Otherwise, it calculates the mean of the data and sets the value of the mean in the cache via the setmean function.
    
    cachemean <- function(x, ...) {
            m <- x$getmean()
            if(!is.null(m)) {
                    message("getting cached data")
                    return(m)
            }
            data <- x$get()
            m <- mean(data, ...)
            x$setmean(m)
            m
    }
    
    In order to complete this assignment, you must do the following:
    
    Fork the GitHub repository containing the stub R files at https://github.com/rdpeng/ProgrammingAssignment2 to create a copy under your own account.
    Clone your forked GitHub repository to your computer so that you can edit the files locally on your own machine.
    Edit the R file contained in the git repository and place your solution in that file (please do not rename the file).
    Commit your completed R file into YOUR git repository and push your git branch to the GitHub repository under your account.
    Submit to Coursera the URL to your GitHub repository that contains the completed R code for the assignment.
    In addition to submitting the URL for your GitHub repository, you will need to submit the 40 character SHA-1 hash (as string of numbers from 0-9 and letters from a-f) that identifies the repository commit that contains the version of the files you want to submit. You can do this in GitHub by doing the following
    willie14 committed Dec 21, 2014
    Configuration menu
    Copy the full SHA
    2b2c572 View commit details
    Browse the repository at this point in the history
Loading