[R] logical vector as a matrix
Linlin Yan
yanlinlin82 at gmail.com
Sat May 30 03:54:01 CEST 2009
On Sat, May 30, 2009 at 2:48 AM, Grześ <gregorio99 at gmail.com> wrote:
>
> I have a vector like this:
> h <- c(4, 6, NA, 12)
> and I create the secound logical vector like this:
> g <- c(TRUE, TRUE, FALSE, TRUE)
Why don't you create vector g like this:
g <- ! is.na(h)
>
> And my problem is that I would like to get a new "m" vector as a rasult "h"
> and "m" but with missed "NA" value, for example:
>
> m = (4,6,12)
> Do you have any idea?
As what you tried to do:
m <- h[g] # which got (4,6,12)
you can directly use:
m <- h[ ! is.na(h) ]
More information about the R-help
mailing list