Skip to content

Room2: volcano script added #11

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dokato
Copy link
Collaborator

@dokato dokato commented Feb 10, 2022

No description provided.

Copy link

@mvab mvab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall good use of tidyverse;

#' This is script with analysis of volcanos for my
#' geological article.

volcano <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-05-12/volcano.csv')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import readr separately


volcano <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-05-12/volcano.csv')

processed_volcano <- volcano %>%
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good use of pipes

Comment on lines +18 to +23
processed_volcano$primary_volcano_type <-
recode(processed_volcano$primary_volcano_type, Stratovolcano="Stratovolcano(es)")

processed_volcano$primary_volcano_type <-
recode(processed_volcano$primary_volcano_type, `Shield(s)`="Shield")

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use mutate for these steps too

summarise(count = n()) %>%
arrange(desc(count)) %>% head(8)

# NA types become Other as we want to include them in the analysis
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as in line 18

sc_max <- max(processed_volcano$pop)
sc_min <- min(processed_volcano$pop)

col_palette = c("#d11141", "#00b159", "#00aedb", "#f37735", "#ffc425",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define constants on the top and keep them upper case

ggplot(aes(longitude, latitude, size = pop)) +
borders(colour = "#396067", fill = "#383949") +
geom_point(shape = 16, colour = dotcol, fill = "#ff5800", alpha = 0.6) +
scale_radius(range = c(1, 8), limits = c(sc_min, sc_max)) +
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are defined outside the function

"#3aefaf", "#0b57dd", "#f666b7", "#cf1833", "#a35c0a",
"#bc0bfe", "#61ff41", "#eabf72", "#09dbc3", "#ffffff")

do_map = function(vulc_type, colid = NULL) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function contains too many magic numbers

"#3aefaf", "#0b57dd", "#f666b7", "#cf1833", "#a35c0a",
"#bc0bfe", "#61ff41", "#eabf72", "#09dbc3", "#ffffff")

do_map = function(vulc_type, colid = NULL) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use <- for assignments

}


plot.list <- lapply(seq(1, length(volcano_types$primary_volcano_type)),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break this lapply into separate lines for readability

}


plot.list <- lapply(seq(1, length(volcano_types$primary_volcano_type)),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use _ instead of . in variable names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants