Skip to content

Commit be938b6

Browse files
committed
adds small examples
1 parent 2e00bda commit be938b6

File tree

3 files changed

+3066
-0
lines changed

3 files changed

+3066
-0
lines changed

Materials/Lab_14/example_r.R

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library(dplyr)
2+
library(ggplot2)
3+
library(MASS)
4+
5+
n_nonzero <- c(10, 100, 200)
6+
n_obs <- c(10000, 1000, 500)
7+
size <- c(1, 2, 5)
8+
9+
single_experiment <- function(non_zero, obs, s) {
10+
runif(1)
11+
}
12+
13+
results_raw <- lapply(n_nonzero, function(non_zero){
14+
lapply(n_obs, function(obs) {
15+
lapply(size, function(s) {
16+
data.frame(
17+
n_nonzero = non_zero,
18+
n_obs = obs,
19+
size = s,
20+
stat = single_experiment(non_zero, obs, s)
21+
)
22+
}
23+
)}
24+
)}
25+
)
26+
27+
bind_rows(unlist(unlist(results_raw, recursive = FALSE), recursive = FALSE)) %>%
28+
ggplot(aes(x = n_obs, y = stat, color = as.character(n_nonzero))) +
29+
geom_point() +
30+
theme_bw() +
31+
facet_wrap(~size)
32+

Materials/Lab_14/rmd_example.Rmd

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "Laboratorium 14"
3+
author: "Mateusz Staniak"
4+
date: "`r format(Sys.time(), '%d - %m - %Y')`"
5+
output:
6+
html_document:
7+
df_print: paged
8+
toc: true
9+
toc_float: true
10+
code_folding: hide
11+
number_sections: true
12+
---
13+
14+
```{r setup, include=FALSE}
15+
library(knitr)
16+
library(ggplot2)
17+
knitr::opts_chunk$set(echo = FALSE,
18+
warning = FALSE,
19+
message = FALSE)
20+
data("ChickWeight")
21+
```
22+
23+
# Tabela
24+
25+
```{r }
26+
kable(head(ChickWeight))
27+
```
28+
29+
Kolumny tej wspaniałej tabeli to `r paste(colnames(ChickWeight))`.
30+
31+
# Wykres
32+
33+
```{r }
34+
ggplot(ChickWeight, aes(x = Time, y = weight, group = Chick)) +
35+
geom_line() +
36+
theme_bw()
37+
```

0 commit comments

Comments
 (0)