-
Notifications
You must be signed in to change notification settings - Fork 0
/
Create_a_log_for_biostatistics_for_sums.rmd
87 lines (73 loc) · 2.28 KB
/
Create_a_log_for_biostatistics_for_sums.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
author: habib Ezatabadi
title: "BioStatistics Sums"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r warning = F, message = F}
library(tidyverse)
library(grid)
library(png)
"patchwork" |> library()
```
***
```{r}
set.seed(769534) # Create example data
f1 <- function(x) 1/64* (x + 20)**2
f2 <- function(x) 1/64 * x**2
f3 <- function(x) 1/64 * (x - 20)**2
seq1 <- f1((-20):(-11))
seq2 <- f2((-10):(9))
seq3 <- f3(10:20)
x1 <- c(-20:20); y1 <- c(seq1, seq2, seq3);
Group <- paste0("line:", (-20):20)
dat <- data.frame(x = x1, xend = x1, y = rep(-.5, 41), yend = y1, Group = Group)
my_plot <- ggplot() +
stat_function(fun = f1, xlim = c(-20, -10), linewidth = 1.5,
colour = "#0a6d17") +
stat_function(fun = f2, xlim = c(-10, 10), linewidth = 1.5,
colour = "#0a6d17") +
stat_function(fun = f3, xlim = c(10, 20), linewidth = 1.5,
colour = "#0a6d17") +
theme(
panel.border = element_blank(),
axis.text = element_blank(),
panel.grid = element_blank(),
axis.ticks = element_blank(),
panel.background = element_rect(fill = "white")
) +
coord_cartesian(x = c(-20, 20), y = c(-1, 2)) +
geom_segment(data = dat, aes(x = x, xend = xend, y = y,
yend = yend, group = Group), colour = "#0a6d17") +
annotate(geom = "text", label = "Bridging", angle = -60, x = -5,
y = f2(-5) + 0.35, colour = "black", size = 10, family = "serif") +
annotate(geom = "text", label = "The", angle = 0, x = 0,
y = f2(0) + 0.15, colour = "black", size = 10, family = "serif") +
annotate(geom = "text", label = "Sciences", angle = 62.5, x = 5,
y = f2(5) + 0.3, colour = "black", size = 10, family = "serif") +
annotate(geom = "text", label = "Departement of Biostatistics
Shiraz University of Medical Sciences",
x = 0, y = -.75, colour = "black", family = "serif",
size = 5) +
labs(x = "", y = "") +
annotate(geom = "segment", x = c(-20, -10, 10),
xend = c(20, -10, 10), y = rep(-0.5, 3), yend =
c(-0.5, f2(-10), f2(10)), linewidth = 1.5,
colour = "#0a6d17")
```
***
```{r}
my_image1 <- readPNG(file.choose())
```
***
```{r}
g <- rasterGrob(my_image1, interpolate=TRUE)
Final_Plot <- my_plot +
annotation_custom(g, xmin = -4, xmax = 4, ymin = 0.5, ymax = 2)
```
***
```{r}
Final_Plot
```