Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a17dea7
commit b1dca96
Showing
13 changed files
with
508 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ | |
^man-roxygen$ | ||
^tmp\.R$ | ||
^inst/useless$ | ||
^\.github$ | ||
^inst/issues$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
PtID,East,North | ||
0816006,149.7519,311.8259 | ||
0816007,153.0656,300.8340 | ||
0816008,143.0636,303.4999 | ||
0816009,146.8176,301.9608 | ||
0916001,169.5130,317.3759 | ||
0916002,169.6355,313.8165 | ||
0916003,167.6531,310.4807 | ||
0916003,167.6606,310.4932 | ||
0916004,164.8548,316.7378 | ||
0916005,165.3046,311.6328 | ||
0916006,165.6578,309.7452 | ||
0916007,162.5376,309.1591 | ||
0916008,161.7250,305.1514 | ||
0916009,163.1855,303.5896 | ||
0916010,164.5169,303.0404 | ||
0916011,165.7609,301.5969 | ||
0916012,178.8555,303.8969 | ||
1017001,198.2785,325.3465 | ||
1017002,187.3418,327.3521 | ||
1017003,182.4314,331.8514 | ||
1017004,185.1744,322.1447 | ||
0818001,152.7749,358.5041 | ||
0818002,155.1088,353.1732 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
title: "Process and explore FastField data of a first census" | ||
output: github_document | ||
params: | ||
input_dir: !r dirname(system.file("extdata", "first_census/census.xlsx", package = "fgeo.tool")) | ||
output_dir: !r tempdir() | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
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} | ||
) | ||
``` | ||
|
||
```{r} | ||
# 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. | ||
|
||
![](https://i.imgur.com/fGOtlVz.png) | ||
|
||
![](https://i.imgur.com/C2SbGMb.png) | ||
|
||
```{r} | ||
# My input directory | ||
params$input_dir | ||
dir(params$input_dir, "xlsx") | ||
# My output directory (temporary) | ||
params$output_dir | ||
``` | ||
|
||
```{r} | ||
xl_sheets_to_csv(params$input_dir, params$output_dir, first_census = TRUE) | ||
# Output is one .csv per workbook | ||
dir(params$output_dir, "csv") | ||
``` | ||
|
||
```{r} | ||
# Now input multiple .csv and output a single dataframe | ||
combo <- csv_to_df(params$output_dir) | ||
combo | ||
``` | ||
|
||
```{r} | ||
# Read data of tree positions | ||
where_dir <- example_path("first_census/position.csv") | ||
where <- read_csv(where_dir) | ||
# Compare | ||
where | ||
select(combo, quadrat, tag) | ||
``` | ||
|
||
```{r} | ||
# 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 | ||
``` | ||
|
||
```{r} | ||
# 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`. | ||
|
||
```{r} | ||
filter(combo2, is.na(date)) | ||
``` | ||
|
Oops, something went wrong.