[R] Looking for a function or a set of steps

Rolf Turner ro||turner @end|ng |rom po@teo@net
Tue May 20 00:25:59 CEST 2025


On Sun, 18 May 2025 13:40:31 -0400
paul zachos via R-help <r-help using 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?


Looks suspiciously like a homework question to me.

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
         +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619



More information about the R-help mailing list