pplr_site_rep: Spatial-temporal replication of data sets

Description Usage Arguments Details Value Examples

View source: R/site_replication.R

Description

Functions to examine the number of temporal replicates contained in each spatial replication level of a dataset. pplr_site_rep_plot plots the temporal replicates available for each site. pplr_site_rep produces logical vectors that identify the spatial replicates with enough temporal replication, or summary tables.

Usage

1
2
3
4
pplr_site_rep(input, freq = 1, duration = 10, rep_level = 1,
  return_logical = TRUE)

pplr_site_rep_plot(input, return_plot = FALSE)

Arguments

input

An object of class get_data. Note that this is not an output from browse, as the raw data is required to calculate the amount of replication.

freq

A number corresponding to the desired annual frequency of temporal replication. Studies that are replicated more frequently will be included in the counts and those that replicated less frequently will be excluded. If return_logical = TRUE, rows included in sites that are replicated at the desired frequency will have a TRUE value, and rows that are not will have FALSE value. Values greater than 1 correspond to sampling multiple times per year. For example, freq = 2 indicates a desired sampling frequency of every 6 months. Values less than 1 indicate sampling intervals of greater than 1 year. For example, freq = 0.5 indicates a desired sampling frequency of once every 2 years.

duration

An integer corresponding to the desired duration of temporal replication. Rows corresponding to sites with more replication will be included, while those with less will be excluded.

rep_level

An integer corresponding to the level of spatial replication desired. Values between 1 and 5 are possible (though higher levels may not be present for some datasets). Higher values correspond to higher levels of spatial nestedness. The default value of rep_level = 1 corresponds to entire sites.

return_logical

Indicates whether to return a summary table of class tbl or a logical vector. The default is TRUE.

return_plot

A logical indicating whether to return a copy of the input data or the ggplot object created by the function. Use TRUE to return the ggplot object for subsequent modification. Use FALSE to return an invisible copy of the input object (useful for piping). Default is FALSE.

Details

pplr_site_rep_plot produces a scatterplot showing the sites (spatial_replication_level_1) and years for which data is available.

pplr_site_rep works with any level of spatial replication and produces either a summary table of temporal replication or a logical vector that can be used to subset a data set based on the desired frequency and length of time.

Value

pplr_site_rep_plot: input object (invisibly) or a ggplot2 object. Use return_plot to control.

pplr_site_rep: A tbl or a logical vector of length dim(input)[1]. Use return_logical to control.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## Not run: 

library(ggplot2)
library(dplyr)

# produce logical vector and subset using it. This can also be piped into a 
# the plotting function for visiualization

good_studies <- pplr_get_data(lterid == 'SEV') %>%
                   .[pplr_site_rep(input = .,
                                   duration = 12, 
                                   rep_level = 3), ] %>%
                   pplr_site_rep_plot()
                                       

# Or, make a neat summary table and decide where to go from there
SEV <- pplr_get_data(lterid == 'SEV')

rep_table <- pplr_site_rep(input = SEV,
                           freq = 0.5,
                           duration = 12,
                           return_logical = FALSE)
 
# pplr_site_rep_plot ---------------
                                                     
# create an unmodified figure
BNZ <- pplr_get_data(lterid == 'BNZ')

pplr_site_rep_plot(BNZ)

# Return the figure instead of the data for subsequent modification
Antarctica <- pplr_get_data(lterid == 'PAL')

pplr_site_rep_plot(Antarctica,
              return_plot = TRUE) + 
   ggtitle("Penguins Rock!")
   
# Use within pipes. Cannot return and modify the figure this way.
pplr_get_data(lterid == 'SEV') %>% 
  pplr_site_rep_plot(return_plot = FALSE) %>%
  pplr_report_metadata()

## End(Not run)

AldoCompagnoni/poplerr documentation built on Oct. 1, 2018, 3:06 p.m.