Hey Gerrit ,
Thanks your solution works
--
View this message in context:
http://r.789695.n4.nabble.com/replacing-values-in-Array-tp4468739p4477758.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
I want to replace some values in my Array
e.g
data- c(1,2,3,4,5,6,7,8,9,10,11,12)
I would like to replace 1,2,3 by 1 , 4,5,6 by 2, 7,8,9 by 3 and 10,11,12 by
4
I am expecting out put
data- 1 1 1 2 2 2 3 3 3 4 4 4
I have tried replace function
replace(data, (data==1 |data==2| data==3),1)
Hello, uday,
e.g.,
(data - 1) %/% 3 + 1
would do the job in your very specific situation, but take a look at
?findInterval
for possibly more interesting (because more general) solutions.
Hth -- Gerrit
On Tue, 13 Mar 2012, uday wrote:
I want to replace some values in my Array
e.g
data-
3 matches
Mail list logo