Skip to content

Commit

Permalink
readme updated and plotting functions tweaked with legend title
Browse files Browse the repository at this point in the history
  • Loading branch information
rammkripa committed Jan 28, 2021
1 parent acabed9 commit 4ac47e1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
3 changes: 2 additions & 1 deletion R/percent_located_disasters.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ percent_located_disasters <- function(.,
ggplot2::xlab("Geocoding") +
ggplot2::ylab("Percent of Disasters") +
ggplot2::ggtitle("Percent of Disasters Geocoded") +
ggplot2::coord_flip()
ggplot2::coord_flip() +
ggplot2::theme(legend.title = ggplot2::element_blank())
}
else {
return(perc_df)
Expand Down
4 changes: 3 additions & 1 deletion R/percent_located_locations.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ percent_located_locations <- function(.,
dplyr::mutate(percent = 100*count/sum(count)) %>%
dplyr::mutate(coords_nonexistent = forcats::as_factor(coords_nonexistent)) %>%
dplyr::mutate(coords_nonexistent = forcats::fct_recode(coords_nonexistent, "Geocode Failed" = "TRUE", "Geocode Success" = "FALSE"))

if (plot_result){
perc_df %>%
ggplot2::ggplot(mapping = ggplot2::aes(x = coords_nonexistent, y = percent, fill = coords_nonexistent))+
Expand All @@ -42,7 +43,8 @@ percent_located_locations <- function(.,
ggplot2::xlab("Geocoding") +
ggplot2::ylab("Percent of Locations") +
ggplot2::ggtitle("Percent of Locations Geocoded") +
ggplot2::coord_flip()
ggplot2::coord_flip()+
ggplot2::theme(legend.title = ggplot2::element_blank())
}
else {
return(perc_df)
Expand Down
17 changes: 14 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The goal of weed is to make the analysis of EM-DAT and related datasets easier,

## Pre Requisites

Installation of the following packages
Installation of the following packages :
readxl,
dplyr,
magrittr,
Expand All @@ -34,7 +34,7 @@ Installation of the following packages
purrr,
tidyr,
forcats,
ggplot2
ggplot2.

You also need a geonames user account if you intend to use the geocoding functionality of this package. Info on how to get one for free is available [here](https://www.geonames.org/manual.html).

Expand Down Expand Up @@ -71,8 +71,11 @@ locationized_data %>%
```

There are two problems with the Dataset as it exists here.

1. Half of our observations, even in this toy dataset, don't have Lat/Long data

2. The Lat/Long here is blatantly wrong.

Lat > 90?
Long > 360?
How is this possible?
Expand All @@ -90,9 +93,17 @@ locationized_data %>%

# Solving Problem 2: Geocoding the Locationized Data

A reminder that you need a geonames username to access this feature of the ``weed`` package.

More info available [here](https://www.geonames.org/manual.html).

```{r preex5, include = FALSE}
dummy_name = "rammkripa"
```

```{r ex5}
geocoded_data <- locationized_data %>%
geocode(geonames_username = "rammkripa")
geocode(geonames_username = dummy_name)
geocoded_data %>%
select(`Dis No`, Location,location_word, lat, lng)
```
Expand Down
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ this package\!

## Pre Requisites

Installation of the following packages readxl, dplyr, magrittr,
Installation of the following packages : readxl, dplyr, magrittr,
tidytext, stringr, tibble, geonames, countrycode, purrr, tidyr, forcats,
ggplot2
ggplot2.

You also need a geonames user account if you intend to use the geocoding
functionality of this package. Info on how to get one for free is
Expand Down Expand Up @@ -64,10 +64,14 @@ locationized_data %>%
#> 6 2020-0164… West Pokot, Elgeyo Marakwet, Kisu… kisumu 116.343 365.935
```

There are two problems with the Dataset as it exists here. 1. Half of
our observations, even in this toy dataset, don’t have Lat/Long data 2.
The Lat/Long here is blatantly wrong. Lat \> 90? Long \> 360? How is
this possible?
There are two problems with the Dataset as it exists here.

1. Half of our observations, even in this toy dataset, don’t have
Lat/Long data

2. The Lat/Long here is blatantly wrong.

Lat \> 90? Long \> 360? How is this possible?

So, we must recode this Lat/Long data

Expand All @@ -83,9 +87,14 @@ locationized_data %>%

# Solving Problem 2: Geocoding the Locationized Data

A reminder that you need a geonames username to access this feature of
the `weed` package.

More info available [here](https://www.geonames.org/manual.html).

``` r
geocoded_data <- locationized_data %>%
geocode(geonames_username = "rammkripa")
geocode(geonames_username = dummy_name)
geocoded_data %>%
select(`Dis No`, Location,location_word, lat, lng)
#> # A tibble: 6 x 5
Expand Down
Binary file modified man/figures/README-ex4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-ex6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-ex62-1.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 4ac47e1

Please sign in to comment.