Convert binary vector to decimal
问题 I have a vector of a binary string: a<-c(0,0,0,1,0,1) I would like to convert this vector into decimal. I tried using the compositions package and the unbinary() function, however, this solution and also most others that I have found on this site require g-adic string as input argument. My question is how can I convert a vector rather than a string to decimal? to illustrate the problem: library(compositions) unbinary("000101") [1] 5 This gives the correct solution, but: unbinary(a) unbinary(