Roelof Wobben
2016-Nov-03 16:40 UTC
[R] coursera course - assgnment - error : Error in which(!is.Na(content[["sulfate"]])) : , could not find function "is.Na"
Hello, I want to try to get all the data of a cloumn namend "sulfate" which is not Na. So I did : corr <- function(directory, threshold = 0) { # lezen van alle bestanden in de directory file_list <- list.files( directory, pattern = "*.csv", full.names = TRUE) # lezen van alle bestanden in a loop # 1) bepalen van de complete_cases # 2) controleren of het hoger/lager is dan de treshold. # 3) als het hoger is. # a) lezen van de nitraat en controleren of het geen Na is # b) lezen van de sulfaat en controleren of het geen Na is. # c) als beide geen Na zijn, dan de correlatie bepalen for(file in file_list) { content <- read.csv(file) if (complete.cases(content) > 0) { sulfate <- which (!is.Na(content[["sulfate"]])) print(sulfate) } } } but now I see the above error. What did I do wrong ? Regards, Roelof
Rui Barradas
2016-Nov-03 17:31 UTC
[R] coursera course - assgnment - error : Error in which(!is.Na(content[["sulfate"]])) : , could not find function "is.Na"
Hello, Just read the error message more carefully. The function name is the (obvious) problem! Try, with all lowercase, is.na() Hope this helps, Rui Barradas Em 03-11-2016 16:40, Roelof Wobben escreveu:> Hello, > > I want to try to get all the data of a cloumn namend "sulfate" which is > not Na. > > So I did : > > corr <- function(directory, threshold = 0) { > > # lezen van alle bestanden in de directory > > file_list <- list.files( directory, pattern = "*.csv", full.names > TRUE) > > # lezen van alle bestanden in a loop > # 1) bepalen van de complete_cases > # 2) controleren of het hoger/lager is dan de treshold. > # 3) als het hoger is. > # a) lezen van de nitraat en controleren of het geen Na is > # b) lezen van de sulfaat en controleren of het geen Na is. > # c) als beide geen Na zijn, dan de correlatie bepalen > > for(file in file_list) { > content <- read.csv(file) > if (complete.cases(content) > 0) { > sulfate <- which (!is.Na(content[["sulfate"]])) > print(sulfate) > > } > > } > > } > > but now I see the above error. > > What did I do wrong ? > > Regards, > > Roelof > > ______________________________________________ > R-help at 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.
Rui Barradas
2016-Nov-03 17:34 UTC
[R] coursera course - assgnment - error : Error in which(!is.Na(content[["sulfate"]])) : , could not find function "is.Na"
Hello again, I've just read your code more carefully and I believe you should read the help page ?complete.cases and run the examples therein. Tip: don't compare the return value with 0, it's nonsense. Rui Barradas Em 03-11-2016 16:40, Roelof Wobben escreveu:> Hello, > > I want to try to get all the data of a cloumn namend "sulfate" which is > not Na. > > So I did : > > corr <- function(directory, threshold = 0) { > > # lezen van alle bestanden in de directory > > file_list <- list.files( directory, pattern = "*.csv", full.names > TRUE) > > # lezen van alle bestanden in a loop > # 1) bepalen van de complete_cases > # 2) controleren of het hoger/lager is dan de treshold. > # 3) als het hoger is. > # a) lezen van de nitraat en controleren of het geen Na is > # b) lezen van de sulfaat en controleren of het geen Na is. > # c) als beide geen Na zijn, dan de correlatie bepalen > > for(file in file_list) { > content <- read.csv(file) > if (complete.cases(content) > 0) { > sulfate <- which (!is.Na(content[["sulfate"]])) > print(sulfate) > > } > > } > > } > > but now I see the above error. > > What did I do wrong ? > > Regards, > > Roelof > > ______________________________________________ > R-help at 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.
David Winsemius
2016-Nov-03 17:59 UTC
[R] coursera course - assgnment - error : Error in which(!is.Na(content[["sulfate"]])) : , could not find function "is.Na"
> On Nov 3, 2016, at 9:40 AM, Roelof Wobben <r.wobben at home.nl> wrote: > > Hello, > > I want to try to get all the data of a cloumn namend "sulfate" which is not Na. > > So I did : > > corr <- function(directory, threshold = 0) { > > # lezen van alle bestanden in de directory > > file_list <- list.files( directory, pattern = "*.csv", full.names = TRUE) > > # lezen van alle bestanden in a loop > # 1) bepalen van de complete_cases > # 2) controleren of het hoger/lager is dan de treshold. > # 3) als het hoger is. > # a) lezen van de nitraat en controleren of het geen Na is > # b) lezen van de sulfaat en controleren of het geen Na is. > # c) als beide geen Na zijn, dan de correlatie bepalen > > for(file in file_list) { > content <- read.csv(file) > if (complete.cases(content) > 0) { > sulfate <- which (!is.Na(content[["sulfate"]])) > print(sulfate) > > } > > } > > } > > but now I see the above error. > > What did I do wrong ?You are sending a request for academic assistance to a mailing list that specifically describes an expectation that you will use the academic assistance resources are your institution of higher learning. Since Coursera is a fee-based enterprise now, I would expect that they have some sort of web-page interface for collaborating with your coursemates. For this and other advice about constructing non-homework questions likely to get answers on Rhelp, you should read the Posting Guide whose link is appended to every distributed post to Rhelp. -- David> > Regards, > > Roelof > > ______________________________________________ > R-help at 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.David Winsemius Alameda, CA, USA