Skip to content
Back to formatted view

Raw Message

Message-ID: <73256E3B-B005-4296-A953-9AC159EE5D4A@licht-malerei.de>
Date: 2009-01-17T17:03:47Z
From: Jörg Groß
Subject: changing a range of values

Hi,


If I have following vector;


x <- c(1,1,1,2,2,3,4,4,5)

and I want to change values in the range of 1 to 3 into the value 1,  
how can I do that?


I tried


x[x == c(1:3)] <- c(1)


but than I get;

  x
[1] 1 1 1 2 1 1 4 4 5



R doesn't change the 2 into a 1.
But why?