Thank you.

I came up  with a slightly more complicated solution than yours myself:
y<- (-1*x) +1
I did not realize that adding a scalar to a vector would add that scalar to 
each element of the vector. Nice! 

> On May 19, 2025, at 4:18 AM, Erich Subscriptions 
> <erich.s...@neuwirth.priv.at> wrote:
> 
> 1-x
> 
>> On 18.05.2025, at 19:40, paul zachos via R-help <r-help@r-project.org> wrote:
>> 
>> Dear R Community
>> 
>> I am an R beginner
>> 
>> I have a vector of ‘1’s and ‘0’s 
>> 
>> x
>> [1] 0 0 1 0 0 1 1 0 1 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0 0
>> [28] 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 0 1 0 0 1 0 0 0 1 1
>> [55] 0 0 1 0 1 0 0 0 1 1 1 1 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0
>> [82] 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1
>> 
>> I would like to generate a new vector  in which the ‘1’s in x become ‘0’s 
>> and the ‘0’s in x become ‘1’s.
>> 
>> How should I go about this?
>> 
>> Thank you,
>> 
>> paz
>> ______________________________________________
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to