-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_script.Rmd
More file actions
48 lines (37 loc) · 1.04 KB
/
my_script.Rmd
File metadata and controls
48 lines (37 loc) · 1.04 KB
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
---
title: "Example RMarkdown script"
author: "Lukas"
date: "`r Sys.Date()`"
output: html_document
---
Import packages I typically need:
```{r message=FALSE, warning=FALSE}
library(tidyverse)
library(lubridate)
library(zoo)
library(readxl)
library(janitor)
library(scales)
```
Set theme and change some defaults on warnings:
```{r}
theme_set(theme_minimal())
theme_update(axis.text.x=element_text(colour="black"),
axis.text.y=element_text(colour="black"),
strip.text = element_text(colour = "black"),
legend.position = "top")
options(dplyr.summarise.inform = FALSE) # disable dplyr 1.0 warnings
```
```{r}
mtcars %>%
group_by(cyl) %>%
summarise(ave = mean(cyl))
```
```{r}
ggplot(mpg, aes(displ, hwy, color = class)) +
geom_jitter(alpha = 0.7, stroke = 0, size = 3) +
labs(x = "Fuel efficiency, miles/gallon", y = "Engine size, litres",
color = "Car class: ", title = "Car comparison",
subtitle = "For 38 models, 1999-2008.",
caption = "Source: US Environmental Protection Agency")
```