An R-package for Simulating Waveform to a Data Frame
You can install the development version of simWaves from GitHub with:
# install.packages("devtools")
devtools::install_github("Lightbridge-KS/simWaves")
library(simWaves)
sim_sinusoid
will simulate any waves from a given function
(e.g. trigonometric functions).
Let’s start with 1 sine wave.
# Simulate to a data frame
df1 <- sim_sinusoid("sin", n = 1)
# Plot
plot(df1, type = "l")
Now, I’ll
change simulating function to cos
with wavelength 2 and amplitude 3.
df2 <- sim_sinusoid("cos", lambda = 2, amp = 3)
plot(df2, type = "l")
You can use sim_sinusoid_lm()
to simulate sinusoidal wave, also, add
linear model ontop.
Let’s create 10 sine waves plus linear model with slope 1 and some random error.
df3 <- sim_sinusoid_lm("sin", n = 10, slope = 1, epsilon_sd = 0.1, by = 0.01)
plot(df3, type = "l")