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:
> m
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
> l
[,1] [,2]
[1,] 9 10
> matric1<-replace(m,m[3,],l)
> matric1
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 9 10
> matric2<-replace(m,m[3,],xy[50,])
> matric2
[,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:
> xy<-cbind(x,y)
> xy
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
> m1<-replace(xy,xy[2,],l)
> m1
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
--
View this message in context:
http://www.nabble.com/How-to-replace-a-pair-of-observations-in-a-matrix--tp22478918p22478918.html
Sent from the R help mailing list archive at Nabble.com.