Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Change Vector Type keep Names

$
0
0

Sorry, if this is a duplicate. I could not find an answer.

I have a named vector (logical in this case):

a <- c("a" = TRUE, "b" = TRUE, "c" = FALSE, "e" = FALSE)

a
a     b     c     e 
TRUE  TRUE FALSE FALSE 

If I turn it into an integer, the names are gone.

> as.integer(a)
[1] 1 1 0 0

How can I prevent this?


Viewing all articles
Browse latest Browse all 201839

Trending Articles