I have a vector like :
> good.genes
A B C D E
FALSE FALSE FALSE TRUE FALSE
I want to get it's reverse which would be:
A B C D E
TRUE TRUE TRUE FALSE TRUE
Would someone help me do this conversion in R?
To reverse a vector in R programming, call rev() function and pass given vector as argument to it. rev() function returns returns a new vector with the contents of given vector in reversed order.
Use the invert() Function From the NumPy Library to Negate a Boolean Value in Python. The invert() function helps in the bitwise inversion of an element or an array of elements.
Convert bool to string: str() You can convert True and False to strings 'True' and 'False' with str() . Non-empty strings are considered True , so if you convert False to strings with str() and then back to bool type with bool() , it will be True .
Just prepend the !
operator. As Richard Scriven pointed out, this operation is called negation.
!good.genes
A B C D E
TRUE TRUE TRUE FALSE TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With