Re: [R] I want to avioid unnecessary value
Dear Grzés, I am not sure whether I fully understand your question, but try either one of the following options: # Data set from Dimitri Liakhovitski's reply df <- data.frame(kol1=c(2,9,4,3),kol2=c(5,6,6,2),kol3=c(9,6,5,1)) # Option 1 with(df, df[ kol1 != 9 & kol2 != 9 & kol3 != 9, ]) # Option 2 index <- apply(df, 1, function(x) !any(x==9)) df[ index ,] HTH, Jorge On Thu, May 14, 2009 at 10:41 AM, Grze¶ wrote: > > I have a database like this: > > "kol1";"kol2";"kol3" ... > "2";"5";"9" > "9";"6";"6" > "4";"6";"5"... > > I looking for a kod in R which let mi aviod in column unnecessary value, > for > example number "9". > > So, if I have: > > Kol1 > 2 > 9 > 4 > 4... > > after loop in R I would like to get my column like this: > Kol1 > 2 > 4 > 4... > > If you have any idea I'll be grateful to you for any idea > -- > View this message in context: > http://www.nabble.com/I-want-to-avioid-unnecessary-value-tp23542066p23542066.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@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. > [[alternative HTML version deleted]] __ R-help@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.
Re: [R] I want to avioid unnecessary value
I am not sure what you are trying to achive. How about: df<-data.frame(kol1=c(2,9,4,3),kol2=c(5,6,6,2),kol3=c(9,6,5,1)) (df) new.df<-df[(!(df[[1]] %in% 9)&!(df[[2]] %in% 9)&!(df[[3]] %in% 9)),] (new.df) But why would you want to delete all the valid values in all the other columns if you have your "unnecessary value" in only one of the columns? Maybe you should restate what you are looking for. Dimitri On Thu, May 14, 2009 at 10:41 AM, Grześ wrote: > > I have a database like this: > > "kol1";"kol2";"kol3" ... > "2";"5";"9" > "9";"6";"6" > "4";"6";"5"... > > I looking for a kod in R which let mi aviod in column unnecessary value, for > example number "9". > > So, if I have: > > Kol1 > 2 > 9 > 4 > 4... > > after loop in R I would like to get my column like this: > Kol1 > 2 > 4 > 4... > > If you have any idea I'll be grateful to you for any idea > -- > View this message in context: > http://www.nabble.com/I-want-to-avioid-unnecessary-value-tp23542066p23542066.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@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. > -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.com __ R-help@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] I want to avioid unnecessary value
I have a database like this: "kol1";"kol2";"kol3" ... "2";"5";"9" "9";"6";"6" "4";"6";"5"... I looking for a kod in R which let mi aviod in column unnecessary value, for example number "9". So, if I have: Kol1 2 9 4 4... after loop in R I would like to get my column like this: Kol1 2 4 4... If you have any idea I'll be grateful to you for any idea -- View this message in context: http://www.nabble.com/I-want-to-avioid-unnecessary-value-tp23542066p23542066.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.