[R] String question
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Nov 29 15:18:38 CET 2006
Try:
# TRUE if all 0 and 1
regexpr("^[01]*$", bits) > 0
# positions of 1s
gregexpr("1", bits)[[1]]
On 11/29/06, Carmen Meier <carmei3 at web.de> wrote:
> Hi to all
> I would to determinate whether bits is a binary code and I would to find
> out the which bit is set to 1
>
> bits <-"00110110"
> I found to detect whether there are only numbers
> all.digits(bits)
> but is there any function to detect whether there are only 0 and 1 in
> the string
>
> And how could I get the f.e the third "bit" from the right hand side
>
> With regards Carmen
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list