Skip to content

Commit

Permalink
Modify example
Browse files Browse the repository at this point in the history
  • Loading branch information
margauxgo committed Apr 3, 2024
1 parent 3aff4e2 commit d477e08
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 4 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ data_long <- wsabrazil |>
values_to = "frequency")
# Create a horizontal bar plot of water source types
ggplot(data_long, aes(x = frequency, y = reorder(water_source, frequency))) +
geom_bar(stat = "identity", fill = "#3399FF") +
plot <- ggplot(data_long, aes(x = frequency, y = reorder(water_source, frequency))) +
geom_col(fill = "#3399FF") +
labs(x = "Frequency", y = "Water Source",
title = "Water Supply in Belém",
caption = "") +
theme(plot.title = element_text(hjust = 0.5, face = "bold", color = "#333333"))
plot + scale_x_continuous(labels = scales::number_format())
```
![](man/figures/water_supply.png)

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,14 @@ data_long <- wsabrazil |>
values_to = "frequency")

# Create a horizontal bar plot of water source types
ggplot(data_long, aes(x = frequency, y = reorder(water_source, frequency))) +
geom_bar(stat = "identity", fill = "#3399FF") +
plot <- ggplot(data_long, aes(x = frequency, y = reorder(water_source, frequency))) +
geom_col(fill = "#3399FF") +
labs(x = "Frequency", y = "Water Source",
title = "Water Supply in Belém",
caption = "") +
theme(plot.title = element_text(hjust = 0.5, face = "bold", color = "#333333"))

plot + scale_x_continuous(labels = scales::number_format())
```

![](man/figures/water_supply.png)
Expand Down
18 changes: 7 additions & 11 deletions data-raw/data_processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ library(janitor)
library(dplyr)

# Read data -------------------------------------------------------------
data_in <- read_csv("data-raw/PA_census_data.csv") |>
data_in <- read_csv2("data-raw/PA_census_data.csv") |>
as_tibble()

# Tidy data ---------------------------------------------------------------
colnames(data_in)[1] <- "col"

# Split column
data <- data_in |>
separate(col = col, into = c("id", "sector_code", "municipality_name", "municipality_code",
"sector_situation", "MR_name", "sector_type", "avg_income",
"total_households", "piped_water", "well_spring_water","stored_rainwater", "other_water_source", "private_bathroom",
"bathroom_sewerage", "bathroom_septic_tank", "bathroom_cesspit", "bathroom_ditch", "bathroom_waterbodies", "bathroom_other",
"V002_h02"), sep = ";", convert = TRUE)
select(-...1, -V002_h02)

data <- data |>
select(-id, -V002_h02)
# Change column names
colnames(data) <- c("sector_code", "municipality_name", "municipality_code",
"sector_situation", "MR_name", "sector_type", "avg_income",
"total_households", "piped_water", "well_spring_water","stored_rainwater", "other_water_source", "private_bathroom",
"bathroom_sewerage", "bathroom_septic_tank", "bathroom_cesspit", "bathroom_ditch", "bathroom_waterbodies", "bathroom_other")

# Modify sector_situation and sector_type variables
data_adjusted_1 <- data |>
Expand Down
Binary file modified data/wsabrazil.rda
Binary file not shown.
Binary file modified inst/extdata/wsabrazil.xlsx
Binary file not shown.
Binary file modified man/figures/water_supply.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d477e08

Please sign in to comment.