[R] R fft on 2D matrix
tlumley at u.washington.edu
Thu Apr 1 18:47:29 CEST 2004
On Thu, 1 Apr 2004, Anne Gosset wrote:
> I am a brand new user of R and I have a really stupid problem: I am
> having troubles applying fft on 2D matrices. I import a data file of
> 256*256 elements with read.table (it is actually a grey scale image, the
> corresponding data file being generated with Matlab), and I find that
> the fft can be applied on one single column of data, but not on one row.
> (Error message: Error in fft(z, inverse) : non-numeric argument )
> Is it the format of the matrix which causes that trouble? (although I
> checked with the editor that the matrix was well imported) Besides this,
> it is not possible to plot one single row of data (strange plot with the
> names of variables appearing).
You probably have a data.frame rather than a matrix, as that is what
read.table() produces. The difference is not obvious to the untrained
eye, but a data.frame is a list of columns of potentially different types,
so a single column reduces to a vector but a single row does not.
Use as.matrix() on your data frame to convert it to a matrix.
More information about the R-help