This is a demonstration of Rmarkdown and ggplot2
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.6 ✓ dplyr 1.0.8
## ✓ tidyr 1.2.0 ✓ stringr 1.4.0
## ✓ readr 2.1.2 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggplot2)
ob = read.csv("~/Dropbox/_Conferences and Workshops/Van Lang University/Van Lang 6-2023/Datasets/osteo-data.csv")
head(ob)
## id sex age weight height fx time.fx prior.fx fnbmd smoking caintake
## 1 3 Male 73 98 175 0 0.55 0 1.08 1 467
## 2 8 Female 68 72 166 0 15.38 1 0.97 0 543
## 3 9 Male 68 87 184 0 5.06 0 1.01 0 384
## 4 10 Female 62 72 173 0 14.25 0 0.84 1 125
## 5 23 Male 61 72 173 0 15.07 0 0.81 1 463
## 6 24 Female 76 57 156 0 12.30 0 0.74 0 471
ggplot(data=ob, aes(x=weight, y=fnbmd)) + geom_point()
## Warning: Removed 94 rows containing missing values (geom_point).
ggplot(data=ob, aes(x=weight, y=fnbmd, col=sex)) + geom_point()
## Warning: Removed 94 rows containing missing values (geom_point).
ggplot(data=ob, aes(x=weight, y=fnbmd, col=sex)) + geom_point() + geom_smooth()
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 94 rows containing non-finite values (stat_smooth).
## Removed 94 rows containing missing values (geom_point).
ggplot(data=ob, aes(x=weight, y=fnbmd, col=sex)) + geom_point() + geom_smooth() + theme(legend.position="top")
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 94 rows containing non-finite values (stat_smooth).
## Removed 94 rows containing missing values (geom_point).