https://github.com/lightbridge-ks/simwaves
R 📦 for Simulate Waveform data
https://github.com/lightbridge-ks/simwaves
data-simulation r-package sinusoidal-wave
Last synced: about 2 months ago
JSON representation
R 📦 for Simulate Waveform data
- Host: GitHub
- URL: https://github.com/lightbridge-ks/simwaves
- Owner: Lightbridge-KS
- License: other
- Created: 2021-12-14T13:13:15.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-14T13:55:36.000Z (about 4 years ago)
- Last Synced: 2025-03-05T19:55:39.362Z (11 months ago)
- Topics: data-simulation, r-package, sinusoidal-wave
- Language: R
- Homepage:
- Size: 104 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# simWaves
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
**An R-package for Simulating Waveform to a Data Frame**
## Installation
You can install the development version of simWaves from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("Lightbridge-KS/simWaves")
```
## Simulate Trigonometric Waves
```{r load-simWaves}
library(simWaves)
```
### Basic Sinusoid Waves
`sim_sinusoid` will simulate any waves from a given function (e.g. trigonometric functions).
Let's start with 1 sine wave.
```{r sim_sin_1}
# 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.
```{r sim_sin_2}
df2 <- sim_sinusoid("cos", lambda = 2, amp = 3)
plot(df2, type = "l")
```
### Sinusoid Waves + Linear Models
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.
```{r sim_sinusoid_lm_1}
df3 <- sim_sinusoid_lm("sin", n = 10, slope = 1, epsilon_sd = 0.1, by = 0.01)
plot(df3, type = "l")
```