Re: [R] Setting all rows of a certain level to NA in a factor

2012-10-22 Thread Pancho Mulongeni
Perfect, thanks -Original Message- From: Rui Barradas [mailto:ruipbarra...@sapo.pt] Sent: Wednesday, October 17, 2012 9:49 PM To: Pancho Mulongeni Cc: r-help@r-project.org Subject: Re: [R] Setting all rows of a certain level to NA in a factor Hello, Try the following. b <- fac

Re: [R] Setting all rows of a certain level to NA in a factor

2012-10-17 Thread Rui Barradas
Hello, Try the following. b <- factor(ifelse(!B20_A %in% c("No ", "Yes"), NA, B20_A), labels = c("No ", "Yes")) str(b) Hope this helps, Rui Barradas Em 17-10-2012 15:51, Pancho Mulongeni escreveu: Hello everyone. My task is set certain levels (that is all rows of that level) as missing v

Re: [R] Setting all rows of a certain level to NA in a factor

2012-10-17 Thread Berend Hasselman
On 17-10-2012, at 16:51, Pancho Mulongeni wrote: > Hello everyone. > My task is set certain levels (that is all rows of that level) as missing > values in factor B20_A. > Excuse the notation, it happens to be a question number in a survey. > So I thought it would work easily by defining the leve

[R] Setting all rows of a certain level to NA in a factor

2012-10-17 Thread Pancho Mulongeni
Hello everyone. My task is set certain levels (that is all rows of that level) as missing values in factor B20_A. Excuse the notation, it happens to be a question number in a survey. So I thought it would work easily by defining the levels and their labels using the 'factor' function. > levels(B2