Hi, Im a R-neewbe!
I want to use fft on a number of measured data points and plot the result. I know the data should result in some sort of freq. but my plot always ends up flat...
As far as I can see my code dose not take my timesteps in considoration and I don't know how I should make it use them?
My code:
test is the name of my csv datafile and contains of 372 obs. and 2 variables. It has the colums "Time" for the date and time the measurments were made, and "H" for the meassurement, heigh.
[(data <- (test))]
#Convert date-time to a timearrey
data$Time <- as.POSIXct(data$Time, format="%Y-%m-%d %H:%M:%S")
timeseries <- ts(data$H, frequency=1, start =1)
#Im not sure if I should use 1 for req. of 12 ( I have 12 measurements each day) but the result is the same regarding of what I use
#Do FFT
fft_result <- fft(timeseries)
#Create freq-array
freq <- (1:length(fft_result)-1)*(1/length(fft_result))
#PlottFFT-result
ggplot()+
geom_line(aes(x = freq, y = Mod(fft_result)), color = 'blue') +
labs(x = "Frekvens", y = "Amplitud") +
ggtitle("Fouriertransform")
And the plot produced always just flatlines...
Hopefull for help!