I don't know if what Hao wanted to do is to hang himself, but if so, perhaps here is one possible rope:
> idx <- which(m > 0, arr.ind=TRUE) > m.nz <- m[idx] > library(akima) > (m.int <- interp.new(idx[,1], idx[,2], m.nz, xo=1:9, yo=1:9, extrap=TRUE)) $x [1] 1 2 3 4 5 6 7 8 9 $y [1] 1 2 3 4 5 6 7 8 9 $z [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 57.1356740 55.18522 38.413800 18.086957 2.300000 0.737908 22. 544616 [2,] 18.8241001 19.35348 3.100000 -20.355403 -41.610566 -51.308028 -40. 090327 [3,] 3.2234619 8.63630 -5.312670 -29.221287 -53.732091 -69.487619 -67. 130408 [4,] 1.1000000 13.75521 4.290890 -17.935507 -43.566514 -63.244671 -67. 612515 [5,] 3.2013295 25.25298 22.408739 4.000000 -20.615776 -42.081126 -51. 038588 [6,] 0.2005624 33.62766 39.538938 27.083292 5.618185 -15.498922 -26. 910566 [7,] -17.2478151 29.37731 46.179546 41.812431 25.633428 7.000000 -4. 730390 [8,] -58.4893169 3.00000 32.828625 38.685475 29.928013 15.913700 6. 000000 [9,] -130.5161684 -53.43667 -9.550716 8.258617 9.000000 1.817369 -3. 604296 [,8] [,9] [1,] 76.7287988 170.407375 [2,] 1.4000000 80.913745 [3,] -37.3029968 28.876027 [4,] -47.3125835 6.953079 [5,] -38.1307000 6.000000 [6,] -19.2592860 16.750369 [7,] -0.2080329 29.451691 [8,] 9.3350825 34.229953 [9,] 0.8303142 21.211142 Note how wild the interpolated/extrapolated values can be... Andy > From: Adaikalavan Ramasamy > > I do not understand your question. If this was not a sparse > matrix, then > I would have asked you refer into the missing value literature. Even > there, people generally remove any columns/rows that have too many > missing values to avoid unreliable results. > > And since this is a sparse matrix, you are going to have too many > missing values on all rows and columns. I could be wrong but if I am, > someone will tell me that soon enough. > > Regards, Adai > > > > On Fri, 2005-08-05 at 12:12 +0000, 吴 昊 wrote: > > Hi, > > I have a sparse matrix.I want to fill values into the > entries whose value > > is 0.The new generated values should come from the > interpolation of the > > values have existed.Does R provide such interpolation > functions which > > operate on Matrix, for example ,such a matrix below > > 0 0 0 0 2.3 0 0 0 0 > > 0 0 3.1 0 0 0 0 1.4 0 > > 0 0 0 0 0 0 0 0 0 > > 1.1 0 0 0 0 0 0 0 0 > > 0 0 0 4 0 0 0 0 6 > > 0 0 0 0 0 0 0 0 0 > > 0 0 0 0 0 7 0 0 0 > > 0 3 0 0 0 0 6 0 0 > > 0 0 0 0 9 0 0 0 0 > > thanks a lot > > hao wu > > > > ______________________________________________ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html