Skip to content

Instantly share code, notes, and snippets.

@philipp-baumann
Created January 4, 2018 14:15
Show Gist options
  • Save philipp-baumann/11860c452e3896665259a5903e8d452b to your computer and use it in GitHub Desktop.
Save philipp-baumann/11860c452e3896665259a5903e8d452b to your computer and use it in GitHub Desktop.
################################################################################
## Task: Select reference samples for soil refence analyses by using
## Kennard-Stones
## sampling algorithm on preprocessed spectra in PCA space
################################################################################
# Load packages
library("tidyverse")
library("simplerspec")
# Read spectral tibble from Rds file
spc_tbl <- read_rds(path = "out/files/spc_tbl.Rds")
ref_samples_2pc <- select_ref_spc(
spc_tbl = spc_tbl,
ratio_ref = 0.15, # ratio of desired reference samples to total sample number
pc = 2, # Number of principal components considered
print = TRUE) # print plot of PCA space
# Test 6 PCs
ref_samples_6pc <- select_ref_spc(
spc_tbl = spc_tbl,
ratio_ref = 0.15, # ratio of desired reference samples to total sample number
pc = 6, # Number of principal components considered
print = TRUE)
## Compare if different samples have been chosen...
ref_samples_2pc$spc_ref$sample_id
ref_samples_6pc$spc_ref$sample_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment