generated from CUB-Computational-Tools/assignment_problem_set
/
example_r_in_rstudio.Rmd
executable file
·69 lines (55 loc) · 1.21 KB
/
example_r_in_rstudio.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
---
title: "Example: R in RStudio"
date: "Last knitted `r format(Sys.Date(), '%d %b %Y')`"
output:
html_document:
df_print: paged
number_sections: yes
toc: yes
toc_float: true
toc_depth: 3
code_folding: show
editor_options:
chunk_output_type: inline
---
> Click into a code cell (the gray blocks below) to select or edit it. To run a selected code cell, hit `Ctrl`+`Shift`+`Enter` (Windows & Linux) / `Command`+`Shift`+`Enter` (MacOS). Make sure that each code cell runs successfully before you move on to the next one.
# $\LaTeX$ Math
This is just markdown that can include latex math.
$$
\begin{align}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{align}
$$
# System Info
```{r}
# session info
sessionInfo()
```
# Custom Function
```{r}
# custom function from scripts/functions.R
source(file.path("scripts", "functions.R"))
test_add(2,5)
```
# Data
```{r, message = FALSE}
# create dataset using dplyr
library(dplyr)
curve <-
tibble(
t = seq(0, 2, by = 0.01),
y = 1 + sin(2 * pi * t)
)
curve
```
# Plot
```{r, fig.width = 8, fig.height = 6}
# plot using ggplot
library(ggplot2)
curve %>%
ggplot() +
aes(t, y) +
geom_line()
```