Skip to content
Prev 173510 / 398506 Next

How to replace a pair of observations in a matrix?

Dear all,

I did this replacement below and its work for the first case but not in the
second case! Please tell me what's wrong with the second case.....

Case 1:
[,1] [,2]
[1,]    1    4
[2,]    2    5
[3,]    3    6
[,1] [,2]
[1,]    9   10
[,1] [,2]
[1,]    1    4
[2,]    2    5
[3,]    9   10
[,1]      [,2]
[1,] 1.000000  4.000000
[2,] 2.000000  5.000000
[3,] 1.855060 -1.865495

(for matric2 xy[50,] is [1.855060, -1.865495]

Case 2:
x          y
 [1,] -1.2138881  1.0270690
 [2,]  0.5167578 -0.5793451
 [3,]  1.3342747 -1.2561305
 [4,]  0.3047976 -0.3411616
 [5,]  1.7300424 -1.9266858
 [6,]  1.6171193 -1.7818126
 [7,] -0.3296678  0.5010075
 [8,]  0.9840971 -0.8801955
 [9,] -0.5187400  0.4149603
[10,]  1.7179670 -1.6482844
x          y
 [1,] -1.2138881  1.0270690
 [2,]  0.5167578 -0.5793451
 [3,]  1.3342747 -1.2561305
 [4,]  0.3047976 -0.3411616
 [5,]  1.7300424 -1.9266858
 [6,]  1.6171193 -1.7818126
 [7,] -0.3296678  0.5010075
 [8,]  0.9840971 -0.8801955
 [9,] -0.5187400  0.4149603
[10,]  1.7179670 -1.6482844

l doesn't replace xy[2,]....(why??????)

Best regards