R/pigeon_pigeon.R

Defines functions pigeon_pigeon

pigeon_pigeon <- function(n = 1, type = "any"){
  pigeon_species <- readRDS("pigeon_species.RDS")
  pigeon_breeds <- readRDS("pigeon_breeds.RDS")

  if(type == "any"){
    pigeon_data <- c(pigeon_breeds, pigeon_species$`Common name`)
  } else if(type == "breeds"){
    pigeon_data <- pigeon_breeds
  } else if(type == "species"){
    pigeon_data <- pigeon_species$`Common name`
  }

  return(sample(pigeon_data, size = n))

}


#### Goals ------

# To Make a package that returns random pigeons
# Also, adjective phrases with pigeons
# Sentences?

#### Getting the data ----
# library(rvest)
# library(tidyverse)
#
# pigeon_html <- read_html("https://en.wikipedia.org/wiki/List_of_wild_pigeon_species")
# pigeon_data_species <- html_table(pigeon_html, fill = TRUE)[[1]]
# saveRDS(pigeon_data_species, file = "pigeon_species.RDS")
#
# pigeon2_html <- read_html("https://en.wikipedia.org/wiki/List_of_pigeon_breeds")
# pigeon_data_breed <- html_nodes(pigeon2_html, css = "ul li") %>% html_text()
# pigeon_data_breed <- pigeon_data_breed[27:750]
# saveRDS(pigeon_data_breed, file = "pigeon_breeds.RDS")
NourAl-Zaghloul/PigeonWeirdR documentation built on March 8, 2020, 1:28 a.m.