Vote count:
0
is there an easy way to get a binary vector of a number. I would like to specify how many bits...
So for example 4 in 4bit would return c(F,T,F,F) or in 6bit c(F,F,F,T,F,F).
So what I want to create is something like this but with about 8 factors (tx)
tx <- factor(c("a", "b", "c"))
ty <- rep(0:(2 ^ length(tx) - 1), each=length(tx))
df <- data.frame(x=tx, y=ty)
df$z <- c(F,F,F,F,F,T,F,T,F,F,T,T,T,F,F,T,F,T,T,T,F,T,T,T)
ggplot(df, aes(x, y, fill = z)) + geom_raster()
Can anybody help me with this?
asked 10 secs ago
create binary vector of a given number
Aucun commentaire:
Enregistrer un commentaire