knitr::opts_chunk$set(
  echo = TRUE,  # {mine}
  comment = "#>",
  collapse = TRUE,
  out.width = "95%",
  fig.align = "center",
  fig.width = 6,
  fig.asp = 0.618,  # 1 / phi
  fig.show = "hold",
  rows.print = 3  # {mine}
)
# https://forestgeo.github.io/fgeo.tool/#installation
library(fgeo.tool)

# Install with `install.packages("pkg")`
library(fs)
library(tidyverse)

Change your input and output directory before knitting this file, and re-run every day you come back from the field.

# My input directory
params$input_dir
dir(params$input_dir, "xlsx")

# My output directory (temporary)
params$output_dir
xl_sheets_to_csv(params$input_dir, params$output_dir, first_census = TRUE)
# Output is one .csv per workbook
dir(params$output_dir, "csv")
# Now input multiple .csv and output a single dataframe
combo <- csv_to_df(params$output_dir)
combo
# Read data of tree positions
where_dir <- fgeo.x::example_path("first_census/position.csv")
where <- read_csv(where_dir)

# Compare
where
select(combo, quadrat, tag)
# Create a variable that we can later use to merge the two datasets
combo <- mutate(combo, PtID = paste0(quadrat, tag))
combo2 <- left_join(combo, where)
# Reorganize columns for easier visualization
combo2 <- select(combo2, PtID, East, North, date, everything())
combo2
# Helpers to avoid duplication
set_brk <- function(max, by) seq(0, max, by)
set_lim <- function(max) c(0, max)

xmax <- 560
ymax <- 360
ggplot(combo2, aes(East, North, color = date)) + 
  geom_point() +
  coord_equal() +
  scale_x_continuous(minor_breaks = set_brk(xmax, 20), limits = set_lim(xmax)) +
  scale_y_continuous(minor_breaks = set_brk(ymax, 20), limits = set_lim(ymax)) +
  theme_bw()

ggplot2 removes missing values from East and North but there may be missing values in date.

filter(combo2, is.na(date))


forestgeo/fgeo.tool documentation built on Sept. 11, 2022, 1:44 a.m.