I have to remove missing data both in character and numeric datatype.I tried using NA condition but it is not working ,please help me to solve this. -- View this message in context: http://www.nabble.com/Handling-missing-data-tp25530192p25530192.html Sent from the R help mailing list archive at Nabble.com.
Hi did you try ?complete.cases or ?na.omit? nadata[complete.cases(nadata),] Regards Petr r-help-bounces at r-project.org napsal dne 21.09.2009 08:16:04:> > I have to remove missing data both in character and numeric datatype.Itried> using NA condition but it is not working ,please help me to solve this. > -- > View this message in context:http://www.nabble.com/Handling-missing-data-> tp25530192p25530192.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Help us to help you, show us the code that you tried, what you expected, and what you saw. Does "using NA condition" mean:> x == NAWhich does not work Or> is.na(x)Which should. -----Original Message----- From: "premmad" <mtechprem at gmail.com> To: "r-help at r-project.org" <r-help at r-project.org> Sent: 9/21/09 12:38 AM Subject: [R] Handling missing data I have to remove missing data both in character and numeric datatype.I tried using NA condition but it is not working ,please help me to solve this. -- View this message in context: http://www.nabble.com/Handling-missing-data-tp25530192p25530192.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list 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.
Consider this sample dataset (displayed [1:3, 1:3]): T1053B T1102A T1129A AKT1 -0.02412174 0.1986057 NA AURKA -0.37109748 -0.4418542 0.04967051 BRAF -0.14589269 -0.1590310 -0.35483226> is.na(dataset[1, 3])TRUE library(impute) library(GeneMeta) imputed.dataset <- impute.knn(as.matrix(dataset)) CRASH! 2009/9/21 Greg Snow <Greg.Snow at imail.org>:> Help us to help you, show us the code that you tried, what you expected, and what you saw. > > Does "using NA condition" ?mean: > >> x == NA > > Which does not work > > Or > >> is.na(x) > > Which should. > > -----Original Message----- > From: "premmad" <mtechprem at gmail.com> > To: "r-help at r-project.org" <r-help at r-project.org> > Sent: 9/21/09 12:38 AM > Subject: [R] ?Handling missing data > > > I have to remove missing data both in character and numeric datatype.I tried > using NA condition but it is not working ,please help me to solve this. > -- > View this message in context: http://www.nabble.com/Handling-missing-data-tp25530192p25530192.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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. > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
Vassilis Golfinopoulos wrote:> Consider this sample dataset (displayed [1:3, 1:3]): > > T1053B T1102A T1129A > AKT1 -0.02412174 0.1986057 NA > AURKA -0.37109748 -0.4418542 0.04967051 > BRAF -0.14589269 -0.1590310 -0.35483226 > >> is.na(dataset[1, 3]) > TRUE > > library(impute) > library(GeneMeta) > > imputed.dataset <- impute.knn(as.matrix(dataset))impute.knn has a second parameter k with default value 10, the number of nearest neighbors to use, in gene space, for imputation. For the example above, there are not 10 nearest neighbors, and unfortunately impute.knn does not check for this. Is this the case with your real data? This might address your problem with impute.knn, a GeneMeta example would help for progress on that front. Martin> CRASH! > > > 2009/9/21 Greg Snow <Greg.Snow at imail.org>: >> Help us to help you, show us the code that you tried, what you expected, and what you saw. >> >> Does "using NA condition" mean: >> >>> x == NA >> Which does not work >> >> Or >> >>> is.na(x) >> Which should. >> >> -----Original Message----- >> From: "premmad" <mtechprem at gmail.com> >> To: "r-help at r-project.org" <r-help at r-project.org> >> Sent: 9/21/09 12:38 AM >> Subject: [R] Handling missing data >> >> >> I have to remove missing data both in character and numeric datatype.I tried >> using NA condition but it is not working ,please help me to solve this. >> -- >> View this message in context: http://www.nabble.com/Handling-missing-data-tp25530192p25530192.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> R-help at r-project.org mailing list >> 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. >> >> ______________________________________________ >> R-help at r-project.org mailing list >> 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. >> > > ______________________________________________ > R-help at r-project.org mailing list > 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.
No, this is part of my dataset. Anyway, this is unlikely to cause the problem. If there are few data, impute.knn actually uses mean imputation (and returns a warning). ----- Original Message ----- From: "Martin Morgan" <mtmorgan at fhcrc.org> To: "Vassilis Golfinopoulos" <vassilis.golfinopoulos at gmail.com> Cc: "Greg Snow" <Greg.Snow at imail.org>; <r-help at r-project.org>; "premmad" <mtechprem at gmail.com> Sent: Monday, September 21, 2009 7:20 PM Subject: Re: [R] Handling missing data> Vassilis Golfinopoulos wrote: >> Consider this sample dataset (displayed [1:3, 1:3]): >> >> T1053B T1102A T1129A >> AKT1 -0.02412174 0.1986057 NA >> AURKA -0.37109748 -0.4418542 0.04967051 >> BRAF -0.14589269 -0.1590310 -0.35483226 >> >>> is.na(dataset[1, 3]) >> TRUE >> >> library(impute) >> library(GeneMeta) >> >> imputed.dataset <- impute.knn(as.matrix(dataset)) > > impute.knn has a second parameter k with default value 10, the number of > nearest neighbors to use, in gene space, for imputation. For the example > above, there are not 10 nearest neighbors, and unfortunately impute.knn > does not check for this. Is this the case with your real data? > > This might address your problem with impute.knn, a GeneMeta example > would help for progress on that front. > > Martin > >> CRASH! >> >> >> 2009/9/21 Greg Snow <Greg.Snow at imail.org>: >>> Help us to help you, show us the code that you tried, what you expected, >>> and what you saw. >>> >>> Does "using NA condition" mean: >>> >>>> x == NA >>> Which does not work >>> >>> Or >>> >>>> is.na(x) >>> Which should. >>> >>> -----Original Message----- >>> From: "premmad" <mtechprem at gmail.com> >>> To: "r-help at r-project.org" <r-help at r-project.org> >>> Sent: 9/21/09 12:38 AM >>> Subject: [R] Handling missing data >>> >>> >>> I have to remove missing data both in character and numeric datatype.I >>> tried >>> using NA condition but it is not working ,please help me to solve this. >>> -- >>> View this message in context: >>> http://www.nabble.com/Handling-missing-data-tp25530192p25530192.html >>> Sent from the R help mailing list archive at Nabble.com. >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list >>> 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. >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list >>> 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. >>> >> >> ______________________________________________ >> R-help at r-project.org mailing list >> 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. >
Reproducible code.....??? premmad wrote:> > I have to remove missing data both in character and numeric datatype.I > tried using NA condition but it is not working ,please help me to solve > this. >----- Blay S KATH Kumasi, Ghana. -- View this message in context: http://www.nabble.com/Handling-missing-data-tp25530192p25531059.html Sent from the R help mailing list archive at Nabble.com.
I have one column x 97 94 91 90 NA NA NA NA I tried i tried this book$r<-ifelse(book$x!=NA,book$x+20,10) expected result 107 104 101 100 10 10 10 10 But got empty column of variable r.How to work with missing values of numeric variables. Why the numeric variable missing is assigned NA but not .,help in easy work for us. -- View this message in context: http://www.nabble.com/Handling-missing-data-tp25539335p25818365.html Sent from the R help mailing list archive at Nabble.com.
What you want is: book$r<-ifelse(is.na(book$r), 10,book$x+20) On Fri, Oct 9, 2009 at 5:46 AM, premmad <mtechprem at gmail.com> wrote:> > I have one column > x > 97 > 94 > 91 > 90 > NA > NA > NA > NA > I tried > book$r<-ifelse(book$x!=NA,book$x+20,10) > I expect to get the result as follows > 107 > 104 > 91 > 90 > 10 > 10 > 10 > 10 > But what i was getting is empty column of variable r.How to solve this > > -- > View this message in context: http://www.nabble.com/Handling-missing-data-tp25539335p25818365.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
1) No need to post multiple times to the list 2) use the is.na function to test if a value is missing, not == or !=> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of premmad > Sent: Friday, October 09, 2009 5:05 AM > To: r-help at r-project.org > Subject: Re: [R] Handling missing data > > > I have one column > x > 97 > 94 > 91 > 90 > NA > NA > NA > NA > I tried > i tried this > book$r<-ifelse(book$x!=NA,book$x+20,10) > expected result > 107 > 104 > 101 > 100 > 10 > 10 > 10 > 10 > > But got empty column of variable r.How to work with missing values of > numeric variables. > Why the numeric variable missing is assigned NA but not .,help in easy > work > for us. > -- > View this message in context: http://www.nabble.com/Handling-missing-data- > tp25539335p25818365.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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.