Re: [R] interpolation function

2005-08-05 Thread Rolf Turner

What you intend strikes me as being pretty silly.  Do not expect R to
work magic for you.  Even if there were such a function as you desire
in R, the results it would give would be effectively meaningless for
data such as you exhibited.

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
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


Re: [R] interpolation function

2005-08-05 Thread 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 +, 吴 昊 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

Re: [R] interpolation function

2005-08-05 Thread Spencer Graves
  I hope you don't take offense at anything said on this list.  My 
philosophy about this is summarized in something I wrote last December 
that has since been immoratlized in the fortunes package:

  library(fortunes)
  fortune(Spencer Graves)

Our great-great grandchilren as yet unborn may read some of the stupid
questions and/or answers that I and perhaps others give from time to 
time. I'd
rather get flamed for saying something stupid in public on this list than to
continue to provide substandard service to the people with whom I work 
because
I perpetrated the same mistake in an environment in which no one 
questioned so
effectively my errors.
-- Spencer Graves (in a discussion on whether answers on R-help 
should be
   more polite)
   R-help (December 2004)

  Best Wishes,
  spencer graves

Rolf Turner wrote:

 What you intend strikes me as being pretty silly.  Do not expect R to
 work magic for you.  Even if there were such a function as you desire
 in R, the results it would give would be effectively meaningless for
 data such as you exhibited.
 
   cheers,
 
   Rolf Turner
   [EMAIL PROTECTED]
 
 __
 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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
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


Re: [R] interpolation function

2005-08-05 Thread tom wright
On Fri, 2005-05-08 at 12:12 +, 吴 昊 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

Does this look like an answer? If anyone knows a better way please tell
me.

 d-c(0,2,3,2,0,3,4,0,0,0,0,0)
 d.mat-matrix(data=d,nrow=4,ncol=3,byrow=TRUE)
 for(i in 1:length(d.mat[1,])){
+ d.mat[,i][d.mat[,i]==0]-mean(d.mat[,i][d.mat[,i]0])
+ }

Thanks
Tom

__
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

Re: [R] interpolation function

2005-08-05 Thread Liaw, Andy
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.30   0.737908  22.
544616
 [2,]   18.8241001  19.35348  3.10 -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.100  13.75521  4.290890 -17.935507 -43.566514 -63.244671 -67.
612515
 [5,]3.2013295  25.25298 22.408739   4.00 -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.00  -4.
730390
 [8,]  -58.4893169   3.0 32.828625  38.685475  29.928013  15.913700   6.
00
 [9,] -130.5161684 -53.43667 -9.550716   8.258617   9.00   1.817369  -3.
604296
 [,8]   [,9]
 [1,]  76.7287988 170.407375
 [2,]   1.400  80.913745
 [3,] -37.3029968  28.876027
 [4,] -47.3125835   6.953079
 [5,] -38.1307000   6.00
 [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 +, 吴 昊 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

Re: [R] interpolation function in R

2005-08-04 Thread Rolf Turner

?approx

?splinefun

__
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


Re: [R] interpolation function in R

2005-08-04 Thread Sundar Dorai-Raj


吴 昊 wrote:
 Hi
 does R provide some interpolation fucntions?
 thank
 
 
 
 
 __
 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

PLEASE do read the posting guide!

help.search(interpolation)

returns

interpSpline(splines)   Create an Interpolation Spline
periodicSpline(splines)
Create a Periodic Interpolation Spline
NLSstClosestX(stats)Inverse Interpolation
approx(stats)   Interpolation Functions
spline(stats)   Interpolating Splines

for example. There may be others in packages I don't have installed as well.

HTH,

--sundar

__
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