-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
72 lines (48 loc) · 1.55 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# simWaves
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
**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")
```