-
Notifications
You must be signed in to change notification settings - Fork 144k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
### Introduction | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
This second programming assignment will require you to write an R | ||
function that is able to cache potentially time-consuming computations. For | ||
example, taking the mean of a numeric vector is typically a fast | ||
function that is able to cache potentially time-consuming computations. | ||
This comment has been minimized.
Sorry, something went wrong.
lfbecerra
|
||
For example, taking the mean of a numeric vector is typically a fast | ||
operation. However, for a very long vector, it may take too long to | ||
compute the mean, especially if it has to be computed repeatedly (e.g. | ||
in a loop). If the contents of a vector are not changing, it may make | ||
sense to cache the value of the mean so that when we need it again, it | ||
can be looked up in the cache rather than recomputed. In this | ||
Programming Assignment you will take advantage of the scoping rules of the R | ||
language and how they can be manipulated to preserve state inside of an | ||
R object. | ||
Programming Assignment you will take advantage of the scoping rules of | ||
the R language and how they can be manipulated to preserve state inside | ||
of an R object. | ||
|
||
### Example: Caching the Mean of a Vector | ||
|
||
|
@@ -76,8 +76,8 @@ Write the following functions: | |
that can cache its inverse. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Brandon780
|
||
2. `cacheSolve`: This function computes the inverse of the special | ||
"matrix" returned by `makeCacheMatrix` above. If the inverse has | ||
already been calculated (and the matrix has not changed), then the | ||
`cachesolve` should retrieve the inverse from the cache. | ||
already been calculated (and the matrix has not changed), then | ||
`cacheSolve` should retrieve the inverse from the cache. | ||
|
||
Computing the inverse of a square matrix can be done with the `solve` | ||
function in R. For example, if `X` is a square invertible matrix, then | ||
|
66 comments
on commit 7f657dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I edited the code online on GitHub webpage. Now I do not understand how to do the next step.
Commit your completed R file into YOUR git repository and push your git branch to the GitHub repository under your account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I am stuck with the same problem. I have an R file but no idea what I need to do with it to make it go to where it is supposed to go... is "MY" git repository the one I cloned? Different one? How do I push and where? Thanks...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whole story is very confusing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very confused . I dont know how add code into this. From where to start. and I am stuck. though I am following instructions but still confused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this thing is pretty darm confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply cannot submit the assignment, the whole process is so confusing. So much time is already wasted, is not there a simpler way to achieve "submission"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I commited my R program to github, but I am not sure.
After clicking a few things I see
"commit ca5f5bcba2631beb764c7a084gg91f8be9bc173a"
Is that it?
I didn't use any git tools - just went on the browser...
Any help appreciated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
86f472e8238985f844590ae71c3ea763e24eea10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, let me know how you make the submitted homework. And check the unconfirmed error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very confusing. I need help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this, hope it is correct and can help those confused classmates:
1: create an account in GitHub
2: create the exactly two same files as the two given under account "rdpeng". They are README.md, and cachematrix.R.
3: in the instruction, we are asked to clone GitHub repository to my computer. But unfortunately my MacOS is too old to clone it. So I skipped this step. What I will do is I will just create the functions in my RStudio
4: Submit my assignment to my repository under my account. I will just copy the functions from RStudio into the file "cachematrix.R" under my account
5: Copy the URL link of my R functions to Coursera.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Prof. Just submitted the assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks freemansugar , your information has cleared my confuse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried put my project but i didn't get. My url project is https://github.com/andrelmfsantos/ProgrammingAssignment2/blob/master/cachematrix.R
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is because you need to follow the instructions from the course Data Scientist's Toolbox?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code submission is very confused. Not sure why do they made so complex ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment submission is very confusing
https://github.com/sujitseth/ProgrammingAssignment2
73d917c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have my homework on my computer but I could not raise it , they could tell me the steps to upload the task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't upload the task nether, I don't understand the process of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am really confused!!
I know the answer but I can not upload the task !!!!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/sarabatash/ProgrammingAssignment2-1.git
This is my project, please review it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by the whole GitHub process also. Just in case this is allowed, this is my submission
https://github.com/chacin/ProgrammingAssignment2.git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been struggling with the assignment submission too - every time I push, it was the old R file instead of my updated R scripts - though I have made changes to it. I do not know what happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone who is confuse about how to submit your assignment to Github, I really suggest you check out the course of _Data Scientists ToolBox_on Coursera, which is also taught by Prof Roger D. Peng.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Its really good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to submit my assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, Peng. I have submitted my work but when I review others work I found that they have two contributors including you, while I only have one. Does this can be a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProgrammingAssignment2-master-DATASCIENTIST59/cachematrix.R
3450aef954a7ee7eee4409c94c1977a37b55035f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you please review my assignment
https://github.com/Mstfait/ProgrammingAssignment2
18abc3d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/thoughtful01/ProgrammingAssignment2
Could anybody please review my assignment? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just committed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/aniket1911/ProgrammingAssignment2.git
29bde57
c719adb
please review mine, I have spent 2 weeks to learn to push it here. Million thanks in advance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. This is my assignment please review and advise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just committed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching the Inverse of a Matrix
Caching the Inverse of a Matrix.docx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A step forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sir by mistake I have linked my branch with the original. Sir please delete it as I am not able to do it. I tried a lot. Sir please do it as soon as possible.
Sorry for the trouble. Please help me with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put comments here that give an overall description of what your
functions do
Caching the Inverse of a Matrix
Write a short comment describing this function
makeCacheMatrix <- function(x = matrix()) {
}
This function creates a special "matrix" object that can cache its inverse.
Write a short comment describing this function
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
}
This function computes the inverse of the special "matrix" returned by makeCacheMatrix above. If the inverse has already been calculated (and the matrix has not changed), then cacheSolve should retrieve the inverse from the cache.
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)
}
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
}
makeCacheMatrix <- function( m = matrix() ) {
i <- NULL
set <- function( matrix ) {
m <<- matrix
i <<- NULL
}
get <- function() {
m
}
setInverse <- function(inverse) {
i <<- inverse
}
getInverse <- function() {
i
}
list(set = set, get = get,
setInverse = setInverse,
getInverse = getInverse)
}
cacheSolve <- function(x, ...) {
m <- x$getInverse()
if( !is.null(m) ) {
message("getting cached data")
return(m)
}
data <- x$get()
m <- solve(data) %*% data
x$setInverse(m)
m
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have confused about the last part. You can add # to explain it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment was confused for me. i dont know where can i see the SHA-1 hash that i need to submit my assignment.
Can all of you go to my assignment and give me a review. Thanks in advance
https://github.com/natymiranda90/ProgrammingAssignment2/blob/main/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so confusing!! I have this code but I really don't know where should I publish it for this assignment!:
makeCacheMatrix <- function(x) {
inv <- NULL
set <- function(y) {
x <<- y
inv <<- NULL # Clear the cached inverse
}
get <- function() {
x
}
setInverse <- function(inverse) {
inv <<- inverse
}
getInverse <- function() {
inv
}
list(set = set, get = get, setInverse = setInverse, getInverse = getInverse)
}
cacheSolve <- function(x) {
inv <- x$getInverse()
if (!is.null(inv)) {
message("Fetching inverse from cache...")
return(inv)
}
matrix <- x$get()
inv <- solve(matrix)
x$setInverse(inv)
inv
}
The makeCacheMatrix function creates a special "matrix" object that can cache its inverse. It takes a matrix x as an argument and returns a list of functions. The functions in the list are used to manipulate and access the matrix object.
The cacheSolve function computes the inverse of the matrix object created by makeCacheMatrix. It checks if the inverse has already been calculated and cached. If the inverse is found in the cache, it is retrieved. Otherwise, it calculates the inverse using solve and caches it for future use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this, hope it is correct and can help those confused classmates: 1: create an account in GitHub 2: create the exactly two same files as the two given under account "rdpeng". They are README.md, and cachematrix.R. 3: in the instruction, we are asked to clone GitHub repository to my computer. But unfortunately my MacOS is too old to clone it. So I skipped this step. What I will do is I will just create the functions in my RStudio 4: Submit my assignment to my repository under my account. I will just copy the functions from RStudio into the file "cachematrix.R" under my account 5: Copy the URL link of my R functions to Coursera.
good work !
Function to create a special "matrix" object that can cache its inverse
makeCacheMatrix <- function(matrix = matrix()) {
create an empty cache
cache <- NULL
Define a list to set and get the matrix
matrixObj <- list(
set = function(newMatrix) {
matrix <<- newMatrix
# Invalidate the cache when matrix is updated
cache <<- NULL
},
get = function() matrix,
# Function to set the inverse of the matrix in the cache
setInverse = function(inverse) cache$inverse <<- inverse,
# Function to get the inverse of the matrix from the cache
getInverse = function() cache$inverse
)
return(matrixObj)
}
Function to compute the inverse of the special "matrix" object
cacheSolve <- function(matrixObj, ...) {
return the matrix from the cache object
matrix <- matrixObj$get()
Check if the inverse is already in the cache
if (!is.null(matrixObj$getInverse())) {
cat("Getting cached inverse:\n")
return(matrixObj$getInverse())
} else {
# If not in cache, get the inverse using solve
inverse <- solve(matrix, ...)
# Cache the computed inverse
matrixObj$setInverse(inverse)
cat("Computing inverse and caching:\n")
return(inverse)
}
}