for (i in seq_along(valores_atuais)) matriz[matriz == valores_na_matriz[i]] = valores_atuais[i]
b 2012/6/28 andrebvs <[email protected]>: > Como atualizo alguns dos seguintes valores da matriz abaixo: > > [,1] [,2] [,3] [,4] [,5] > [1,] 3 19 22 27 34 > [2,] 3 12 22 34 43 > [3,] 3 12 27 43 54 > [4,] 12 19 27 34 43 > [5,] 4 16 21 36 41 > [6,] 4 9 16 30 41 > [7,] 4 9 21 30 36 > [8,] 9 16 21 36 41 > [9,] 5 8 24 35 47 > [10,] 5 15 24 38 52 > [11,] 5 8 15 35 38 > [12,] 8 15 24 38 52 > [13,] 7 11 23 39 46 > [14,] 7 18 32 46 49 > [15,] 7 11 18 23 39 > [16,] 11 18 32 39 46 > [17,] 3 16 23 35 54 > [18,] 3 5 16 36 46 > [19,] 3 5 23 35 46 > [20,] 5 16 35 36 54 > [21,] 4 7 22 30 47 > [22,] 4 22 24 30 34 > [23,] 4 7 24 34 47 > [24,] 7 22 24 34 49 > [25,] 8 19 21 32 43 > [26,] 8 11 21 38 43 > [27,] 8 19 32 38 50 > [28,] 11 19 21 32 43 > [29,] 9 12 18 39 41 > [30,] 9 15 27 39 52 > [31,] 9 12 15 18 27 > [32,] 12 18 27 39 41 > [33,] 3 15 21 35 39 > [34,] 3 4 21 22 39 > [35,] 3 15 22 35 47 > [36,] 4 15 21 22 39 > [37,] 5 7 19 38 46 > [38,] 5 19 27 38 54 > [39,] 5 7 23 27 46 > [40,] 7 23 27 38 46 > > Os valores a serem atualizados (sbstituídos) da matriz são: > > valores_na_matriz <- > c(9,11,12,15,18,19,21,22,23,24,27,30,32,35,36,39,41,46,52,54,55,56,57,58) > > Pelos correspondentes valores abaixo: > > valores_atuais <- > c(10,12,13,14,17,23,24,25,28,29,30,32,33,36,37,41,42,44,51,52,53,54,59,60) > > ou seja, substituir na: 9 por 10, 11 por 12, 12 poe 13, ..., 58 por 60. > > desde já agradeço! > > Att. > André > > > _______________________________________________ > R-br mailing list > [email protected] > https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br > Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código > mínimo reproduzível. _______________________________________________ R-br mailing list [email protected] https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.
