Skip to content

Commit

Permalink
My contribution of a bar plot
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkumar committed Aug 28, 2023
1 parent 4f40c30 commit b3cbf0d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 11d-plots-example-bar.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
### Bar Plot

A simple example to show how to make a bar plot.

```{r, message = FALSE, warning = FALSE, error = FALSE}
### load relevant libraries and data
library(dplyr)
library(haven)
library(ggplot2)
adam_path <- "https://github.com/phuse-org/TestDataFactory/raw/main/Updated/TDF_ADaM/"
adsl <- read_xpt(paste0(adam_path, "adsl.xpt"))
```

First we create a basic bar plot

```{r, message = FALSE, warning = FALSE, error = FALSE}
# create plot
ggplot(data = adsl, aes(x = SITEID)) +
geom_bar()
```

Next, we add some customizations. Here I will cover each bar by SEX, and specify a theme
```{r, message = FALSE, warning = FALSE, error = FALSE}
# create plot
ggplot(data = adsl, aes(x = SITEID, fill = SEX)) +
geom_bar() +
theme_classic()
```

0 comments on commit b3cbf0d

Please sign in to comment.