Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My contribution of a bar plot #24

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
```
Loading