Penguins

Author

alex

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

#install.packages("rinat")

#next you need to tell R to load the packages you just installed. You need to do this every time you open R.
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.6
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.1     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.2.0     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(rinat)

#  Plotting the data in Washington
beav_inat_wa <- get_inat_obs(
  taxon_name = "beaver",
  #taxon_id = "43794",       #American Beaver 43794
  place_id = 46,            #46 is for Washington, 502 is Clark County       
  geo = TRUE,               #Specifies that we want geocoordinates
  maxresults = 4000,        #Limits results... 
  meta = FALSE                
)

states <- map_data("state")
washington <- states %>%
  filter(region %in% ("washington"))    #make sure to use lowercase.
which_state <- "washington"
county_info <- map_data("county", region=which_state)  # county boundaries

beav_ggplot <-
  ggplot(data = county_info) +             
  geom_polygon(aes(x = long,              #base map
                   y = lat,
                   group = group),
               fill = "white",            #background color
               color = "darkgray") +      #border color
  coord_quickmap() +
  geom_point(data = beav_inat_wa,             
             mapping = aes(
               x = longitude,
               y = latitude,
               fill = quality_grade),   #changes color of point based
             color = "black",             #outline of point
             shape= 21,                   #this is a circle that can be filled
             alpha= 0.7) +                #alpha sets transparency (0-1) 
  theme_bw() +                            #just a baseline theme
  theme(
    plot.background= element_blank(),     #removes plot background
    panel.background = element_rect(fill = "white"),  #sets panel background
    panel.grid.major = element_blank(),               #removes x/y major gridlines
    panel.grid.minor = element_blank())               #removes x/y minor gridlines

beav_ggplot                                         #this allows you to see the map

You can add options to executable code like this

The echo: false option disables the printing of code (only output is displayed).