Sunday, August 23, 2015

Useful R tips #1

Clear all user-defined objects and functions


rm(list = ls())

This command will clear all functions and objects defined (or in memory). Why would you want to do that? Sometimes, functions and variables may not contain the expected values (or behavior) . As is often the case, they may be sharing a name with another global variable or function previously defined. What may happen spans the  full spectrum of what the hell. You do not need to run this command every time, perhaps only at the start of a new R session.


Normalized Inverse Fast Fourier transform (FFT)


fft(z, inverse = TRUE) / length(z)

Taking the inverse FFT in R has a peculiar side-effect. The results are almost always not normalized. In the last activity, this means that after clipping selected frequencies in the power-spectrum, plotting the descriptor (from the inverse FFT) will not overlap with the original. Normalizing the inverse yields the "expected" result.

No comments:

Post a Comment