Apologies Ana, Of course Rui and Herve (and Richard) are correct here
in stating that NA values get 'carried through' when selecting using
the "==" operator.
To give an illustration of what (I believe) Herve means by "NAs
propagating", here's a small 11 x 8 dataframe ("zakaria") posted to
R-Help l
I think the problem may lie in your understanding of what "==" does with NA
and/or what "[]" does with NA.
> x <- c(NA, "Yes")
> x == "Yes"
[1] NA TRUE
Since you say you DON'T want the rows with "Yes", you just want
x[is.na(x)]
or in your case
t11 <- t1[is.na(t1$sex_chromosome_aneuploidy_f22019_0
Hi,
On 10/3/19 11:58, Ana Marija wrote:
> Hello,
>
> I have a dataframe (t1) with many columns, but the one I care about it this:
>> unique(t1$sex_chromosome_aneuploidy_f22019_0_0)
> [1] NA"Yes"
>
> it has these two values.
>
> I would like to remove from my dataframe t1 all rows which have
Hello again,
Sometimes it's better to create indices for each condition and then
assemble them with logical operations as needed.
i <- t1$sex_chromosome_aneuploidy_f22019_0_0 == "Yes"
j <- is.na(t1$sex_chromosome_aneuploidy_f22019_0_0)
t1[!i & j, ]
j means is.na(.)
!i means (.) != "Yes"
Hello,
Then it's easier, is.na alone will do it.
j <- is.na(t1$sex_chromosome_aneuploidy_f22019_0_0)
t1[j, ]
Hope this helps,
Rui Barradas
Às 20:29 de 03/10/19, Ana Marija escreveu:
Hi Rui,
sorry for confusion, I would only need to extract from my t1 dataframe
rows which have NA in sex_ch
Hello,
I expected the code you posted to work just as you presumed it would,
but without a reproducible example--I can only speculate as to why it
didn't.
In the t1 dataframe, if indeed you only want to remove rows of the
t1$sex_chromosome_aneuploidy_f22019_0_0 column which are undefined,
you cou
Hello,
You have to use is.na to get the NA values.
t1 <- data.frame(sex_chromosome_aneuploidy_f22019_0_0 = c(NA, "Yes"),
other = 1:2)
i <- t1$sex_chromosome_aneuploidy_f22019_0_0 == "Yes" &
!is.na(t1$sex_chromosome_aneuploidy_f22019_0_0)
i
t1[i, ]
Hope this helps,
Rui Bar
7 matches
Mail list logo