Title: | Popler R Package |
---|---|
Description: | Browse and query the popler database. |
Authors: | Compagnoni Aldo [cre, aut], Bibian Andrew [aut], Ochocki Brad [aut], Levin Sam [aut], Miller Tom [aut], Benjamin Bond-Lamberty [rev] (Ben reviewed the package for ropensci, see <https://github.com/ropensci/software-review/issues/254>), Corinna Gries [rev] (Corinna reviewed the package for ropensci, see <https://github.com/ropensci/software-review/issues/254>) |
Maintainer: | Compagnoni Aldo <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2024-10-28 06:22:58 UTC |
Source: | https://github.com/ropensci/popler |
Subsets a browse
or get_data
object based on
logical statements.
## S3 method for class 'browse' filter(.data, ...) ## S3 method for class 'get_data' filter(.data, ...)
## S3 method for class 'browse' filter(.data, ...) ## S3 method for class 'get_data' filter(.data, ...)
.data |
A |
... |
logical conditions |
Add new columns to a browse
or get_data
object.
## S3 method for class 'browse' mutate(.data, ...) ## S3 method for class 'get_data' mutate(.data, ...)
## S3 method for class 'browse' mutate(.data, ...) ## S3 method for class 'get_data' mutate(.data, ...)
.data |
A |
... |
Name-value pairs of expressions. Use |
popler
is a package for interacting with the PostgreSQL data base
with the same name. popler
contains data on long-term population
dynamics from the LTER network. Every exported function is prefixed with
pplr_
and then a verb (e.g. pplr_get_data()
or noun (e.g.
pplr_citation
. Accessing popler
does not require an API key,
all you need is an internet connection and you are ready to go!
Aldo Compagnoni [email protected]
Andrew Bibian [email protected]
Brad Ochocki [email protected]
Sam Levin [email protected]
Tom Miller [email protected]
pplr_browse() reports the metadata of LTER studies contained in the popler database. The user can subset which datasets, and which metadata variables to visualize.
pplr_browse(..., full_tbl = FALSE, vars = NULL, view = FALSE, keyword = NULL, report = FALSE)
pplr_browse(..., full_tbl = FALSE, vars = NULL, view = FALSE, keyword = NULL, report = FALSE)
... |
A logical expression to subset the table containing the metadata of datasets contained in popler |
full_tbl |
logical; Should the function returns the standard
columns, or the full main table? Default is |
vars |
A vector of characters in case the user want to select which variables of popler's main table should be selected? |
view |
If TRUE, opens up a spreadsheet-style data viewer. |
keyword |
A string used to select individual datasets based on pattern matching. The string is matched to every string element in the variables of the metadata table in popler. |
report |
logical; If |
A data frame combining the metadata of each project and the taxonomic units associated with each project.
This data frame is of class popler
, data.frame
,
tbl_df
, and tbl
.
## Not run: # No arguments return the standard 16 columns of popler's main table default_vars = pplr_browse() # full_tbl = TRUE returns the full table all_vars = pplr_browse(full_tbl = TRUE) # subset only data from the sevilleta LTER, and open the relative report in a html page sev_data = pplr_browse(lterid == "SEV", report = TRUE) # consider only plant data sets plant_data = pplr_browse(kingdom == "Plantae") # Select only the data you need three_columns = pplr_browse(vars = c("title","proj_metadata_key","genus","species")) # Select only the data you need study_21 = pplr_browse( proj_metadata_key == 25) # Select studies that contain word "parasite" parasite_studies = pplr_browse( keyword = "parasite") ## End(Not run)
## Not run: # No arguments return the standard 16 columns of popler's main table default_vars = pplr_browse() # full_tbl = TRUE returns the full table all_vars = pplr_browse(full_tbl = TRUE) # subset only data from the sevilleta LTER, and open the relative report in a html page sev_data = pplr_browse(lterid == "SEV", report = TRUE) # consider only plant data sets plant_data = pplr_browse(kingdom == "Plantae") # Select only the data you need three_columns = pplr_browse(vars = c("title","proj_metadata_key","genus","species")) # Select only the data you need study_21 = pplr_browse( proj_metadata_key == 25) # Select studies that contain word "parasite" parasite_studies = pplr_browse( keyword = "parasite") ## End(Not run)
pplr_browse
or
pplr_get_data
object.Returns a bibliography, Bibtex citations, and acknowledgment template.
pplr_citation(input, bibtex_path = NULL)
pplr_citation(input, bibtex_path = NULL)
input |
An object of class |
bibtex_path |
Specify the filename and location for the generated markdown file (optional). |
A list of references from input
.
## Not run: # make a browse object metadata <- pplr_browse(proj_metadata_key %in% c(17, 317, 494)) # cite the projects cite <- pplr_citation(metadata) # cite$bibliography # the bibliography # cite$Bibtex # Bibtex entries for each dataset # cite$acknowledgement # acknowledgement template ## End(Not run)
## Not run: # make a browse object metadata <- pplr_browse(proj_metadata_key %in% c(17, 317, 494)) # cite the projects cite <- pplr_citation(metadata) # cite$bibliography # the bibliography # cite$Bibtex # Bibtex entries for each dataset # cite$acknowledgement # acknowledgement template ## End(Not run)
pplr_get_data()
Create a data frame by "extracting" the covariates
column
contained in an dataset downloaded with pplr_get_data()
.
pplr_cov_unpack(input)
pplr_cov_unpack(input)
input |
An object of class |
A data frame whose columns represent the covariates of the dataset
downloaded via pplr_get_data()
. Note that these covariates are
contained in the covariates
column datasets downloaded using
pplr_get_data()
.
## Not run: library(dplyr) demo_d <- pplr_get_data(proj_metadata_key == 8) as.tbl( pplr_cov_unpack( demo_d ) ) ## End(Not run)
## Not run: library(dplyr) demo_d <- pplr_get_data(proj_metadata_key == 8) as.tbl( pplr_cov_unpack( demo_d ) ) ## End(Not run)
Describes the metadata variables contained in the popler database, and shows their content.
pplr_dictionary(..., full_tbl = FALSE)
pplr_dictionary(..., full_tbl = FALSE)
... |
A sequence of (unquoted) variables specifying one or more variables of popler's main table for which dictionary information is needed |
full_tbl |
logical; If |
## Not run: # Column names column_names <- pplr_dictionary(full_tbl = FALSE) # Dictionary information dictionary_lter <- pplr_dictionary(lterid, full_tbl = FALSE) # multiple columns dictionary_lter_lat <- pplr_dictionary(lterid,lat_lter, full_tbl = FALSE) ## End(Not run)
## Not run: # Column names column_names <- pplr_dictionary(full_tbl = FALSE) # Dictionary information dictionary_lter <- pplr_dictionary(lterid, full_tbl = FALSE) # multiple columns dictionary_lter_lat <- pplr_dictionary(lterid,lat_lter, full_tbl = FALSE) ## End(Not run)
This function downloads datasets contained in the popler database.
The user can download data directly, using a logical expression, or indirectly,
using objects created by pplr_browse
.
pplr_get_data(..., cov_unpack = FALSE)
pplr_get_data(..., cov_unpack = FALSE)
... |
An object produced by |
cov_unpack |
logical; if |
. By default, the following variables are included when a user calls
pplr_get_data()
.
authors
authors_contact
year
day
month
sppcode
genus
species
datatype
spatial_replication_level_1_label
spatial_replication_level_1
spatial_replication_level_2_label
spatial_replication_level_2
spatial_replication_level_3_label
spatial_replication_level_3
spatial_replication_level_4_label
spatial_replication_level_4
spatial_replication_level_5_label
spatial_replication_level_5
proj_metadata_key
structure_type_1
structure_type_2
structure_type_3
structure_type_4
treatment_type_1
treatment_type_2
treatment_type_3
covariates
This data fame is of class get_data
, and data.frame
.
## Not run: # browse a study, then get the data associated with it parasite = pplr_browse(proj_metadata_key == 25) gh_data = pplr_get_data(parasite) # insect data sets from the SEV lter site insect_sev = pplr_browse(class == "Insecta" & lterid == "SEV") insect_25_yrs96_99 = pplr_get_data(insect_sev) insect_21_25 = pplr_get_data( (proj_metadata_key == 43 | proj_metadata_key == 25) ) ## End(Not run)
## Not run: # browse a study, then get the data associated with it parasite = pplr_browse(proj_metadata_key == 25) gh_data = pplr_get_data(parasite) # insect data sets from the SEV lter site insect_sev = pplr_browse(class == "Insecta" & lterid == "SEV") insect_25_yrs96_99 = pplr_get_data(insect_sev) insect_21_25 = pplr_get_data( (proj_metadata_key == 43 | proj_metadata_key == 25) ) ## End(Not run)
Generates maps of LTER sites in a given input
object.
Sizes of site markers correspond to the number of studies at a given site.
pplr_maps(input, return_plot = FALSE)
pplr_maps(input, return_plot = FALSE)
input |
An object created by either |
return_plot |
logical; if |
The input
object (invisibly) or a ggplot2
object.
## Not run: library(dplyr) # make %>% available browse_object <- pplr_browse(proj_metadata_key == 11) browse_object %>% pplr_maps() ## End(Not run)
## Not run: library(dplyr) # make %>% available browse_object <- pplr_browse(proj_metadata_key == 11) browse_object %>% pplr_maps() ## End(Not run)
Load the webpage containing the metadata of the data sets
contained in objects produced by pplr_browse
or downloaded through
pplr_get_data()
. If you downloaded data from multiple projects,
this function will open multiple webpages. This is a wrapper of function
browseURL
in base
.
pplr_metadata_url(input)
pplr_metadata_url(input)
input |
An object produced by the function |
## Not run: # Load the metadata webpages of the projects that contain data from the Poa genus. fes_d <- pplr_browse(genus == "Festuca") pplr_metadata_url( fes_d ) ## End(Not run)
## Not run: # Load the metadata webpages of the projects that contain data from the Poa genus. fes_d <- pplr_browse(genus == "Festuca") pplr_metadata_url( fes_d ) ## End(Not run)
Provides information on the variables of metadata contained in the popler database, and the kind of data contained in those variables.
pplr_report_dictionary(full_tbl = FALSE, md_file = NULL, html_file = NULL)
pplr_report_dictionary(full_tbl = FALSE, md_file = NULL, html_file = NULL)
full_tbl |
logical; if |
md_file |
Specify the filename and location for the generated markdown file (optional) |
html_file |
Specify the filename and location for the generated html file (optional) |
This function is called for its side effects and does not return an R object.
## Not run: # Full dictionary pplr_report_dictionary(full_tbl = TRUE) # "Abridged" version pplr_report_dictionary() ## End(Not run)
## Not run: # Full dictionary pplr_report_dictionary(full_tbl = TRUE) # "Abridged" version pplr_report_dictionary() ## End(Not run)
Generates a readable report of the metadata describing data sets contained in popler. The report contains citations, the links to the original URL of each data set, and example code to obtain the metadata and data of the projects represented in the html page.
pplr_report_metadata(input, md_file = "./browse.Rmd", html_file = "./browse.html")
pplr_report_metadata(input, md_file = "./browse.Rmd", html_file = "./browse.html")
input |
A popler object returned by |
md_file |
Specify the filename and location for the generated markdown file (optional) |
html_file |
Specify the filename and location for the generated html file (optional) |
An invisible copy of input
.
## Not run: # Full dictionary one_spp <- pplr_browse(community == "no" & duration_years > 15) pplr_report_metadata(one_spp) data <- pplr_get_data(one_spp) pplr_report_metadata(data) # same as above ## End(Not run)
## Not run: # Full dictionary one_spp <- pplr_browse(community == "no" & duration_years > 15) pplr_report_metadata(one_spp) data <- pplr_get_data(one_spp) pplr_report_metadata(data) # same as above ## End(Not run)
search
pplr_search(proj_metadata_key, limit = 10, offset = 0, ...)
pplr_search(proj_metadata_key, limit = 10, offset = 0, ...)
proj_metadata_key |
project metadata key |
limit |
number of records to return, default: 10 |
offset |
record number to start at, default: first record |
... |
curl options passed on to [crul::HttpClient] |
# basic example pplr_search(proj_metadata_key = 13) # pass in curl options for debugging, seeing http request details pplr_search(proj_metadata_key = 13, verbose = TRUE)
# basic example pplr_search(proj_metadata_key = 13) # pass in curl options for debugging, seeing http request details pplr_search(proj_metadata_key = 13, verbose = TRUE)
Functions to examine the number of temporal replicates
contained within 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.
pplr_site_rep(input, freq = 1, duration = 10, rep_level = 1, return_logical = TRUE) pplr_site_rep_plot(input, return_plot = FALSE)
pplr_site_rep(input, freq = 1, duration = 10, rep_level = 1, return_logical = TRUE) pplr_site_rep_plot(input, return_plot = FALSE)
input |
An object of produced by |
freq |
A number corresponding to the desired annual frequency of
replicates. Studies that are replicated more frequently will be
included in the counts and those that replicated less frequently will be
excluded.
If |
duration |
An integer corresponding to the desired number of yearly replicates. Rows containing site information from 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 over which verify yearly temporal replication. 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 |
return_logical |
logical; if |
return_plot |
A logical indicating whether to return a copy of the
|
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.
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.
## 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)
## 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)
search
pplr_summary(limit = 10, offset = 0, ...)
pplr_summary(limit = 10, offset = 0, ...)
limit |
number of records to return, default: 10 |
offset |
record number to start at, default: first record |
... |
curl options passed on to [crul::HttpClient] |
# basic example pplr_summary() # pass in curl options for debugging, seeing http request details pplr_summary(verbose = TRUE)
# basic example pplr_summary() # pass in curl options for debugging, seeing http request details pplr_summary(verbose = TRUE)
popler
's summary tableAutomatically retrieve most up to date version of popler
summary table
pplr_summary_table_update()
pplr_summary_table_update()
This function is called for its side effect and does not return anything
The summary_table
is often called internally by popler functions,
but can also be accessed directly by calling pplr_summary_table_import()
.