Re: How to Do a Replacement with Two Conditions
- To: mathgroup at smc.vnet.net
- Subject: [mg119711] Re: How to Do a Replacement with Two Conditions
- From: Dan <dflatin at rcn.com>
- Date: Sat, 18 Jun 2011 06:14:03 -0400 (EDT)
- References: <itejv3$s36$1@smc.vnet.net>
On Jun 17, 12:08 am, Gregory Lypny <gregory.ly... at videotron.ca> wrote:
> Hello everyone,
>
> I have a list of integers and I want to replace numbers bigger than 180 with one and those less than or equal to 180 with 0 to create a dummy variable. The ones are easy:
>
> myList /. x_ /; x > 180 -> 1
>
> How do I get the zeros in there?
>
> Regards,
>
> Gregory
Clip is made for this kind of problem.
Clip[myList-180,{0,1}]