title: How to get the sample frequency axis in R?
body: <p>Im trying to plot a time series data in the frequency domain in R. I have a csv file with columns/signals <code>x</code>, <code>y</code> and <code>z</code>. The Signal has been sampled with frequency of 50 Hz. Length of the data are <code>N=651</code>.</p>
  
  <p>I did the following steps for the column/signal <code>x</code>:</p>
  
  <ol>
  <li><p>FFT of signal <code>x</code>:</p>
  
  <p><code>y &lt;- fft(data$x)</code></p></li>
  <li><p>Calcluating the magnitude of signal <code>x</code>:</p>
  
  <p><code>mag &lt;- sqrt(Re(y)^2+Im(y)^2)</code></p></li>
  <li><p>Plot the data:</p>
  
  <p><code>plot(mag, xlab="Samples",ylab="Strength", type="l", col="blue", xlim=c(0,60), main="Spectrum",t="h",lwd=2)</code></p></li>
  </ol>
  
  <p>What I want is to get an x-axis in frequenzy(Hz) instead of number of samples. In the end I want to get a plot with y-axis (strength) vs. x-axis (Hz). </p>
  
  <p>I want a frequency axis like this: 10Hz,20Hz,30Hz,40Hz,50Hz, etc.</p>
  
  <p>What do I need to do to get the frequency axis in Hz instead of number of samples?</p>