How to create FFT of accelerometer data using signal package

Hi guys, I'm very new to R and I'm attempting to create FFTs from the accelerometer data I have with the "signal" package. However, I am very lost with how to start. Any guidance is appreciated! Here is what I have so far:

library(tidyverse)
library(plotly)

#Sample Data: Sampling Rate = 1kHz, Pulse Width = 100 ms, Duty Cycle = 50%
#Last line: 45195
sample_data <- read.csv("accelerometer.csv")

view(sample_data)

#------------------------Extract "On" Data--------------------------------------
sample_On <- filter(sample_data, on.off == "on")
sample_On

#--------------------Extract Last 10% of Each Pulse-----------------------------
last_ten <- filter(sample_On, row_number() %% 45==0 |
row_number() %% 46==0|
row_number() %% 47==0|
row_number() %% 48==0|
row_number() %% 49==0|
row_number() %% 50==0)
last_ten

#----------------------------Graphs---------------------------------------------
fig1 <- plot_ly(data=last_ten,
x = ~time..ms.,
y = ~x,
name = 'x',
type = "scatter",
mode = "lines")

fig2 <- plot_ly(data=last_ten,
x = ~time..ms.,
y = ~y,
name = 'y',
type = "scatter",
mode = "lines")

fig3 <- plot_ly(data=last_ten,
x = ~time..ms.,
y = ~z,
name = 'z',
type = "scatter",
mode = "lines")

fig <- subplot(fig1, fig2, fig3, nrows = 3) %>%
layout(title = list(text = "Accelerometer 1"),
plot_bgcolor='#e5ecf6',
xaxis = list(
zerolinecolor = '#ffff',
zerolinewidth = 2,
gridcolor = 'ffff'),
yaxis = list(
zerolinecolor = '#ffff',
zerolinewidth = 2,
gridcolor = 'ffff'))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.