Skip to contents

Search over all networks using a keyword, a custom query or a spatial object If the query is a character string, then all character columns in the table are searched and the entries for which at least one partial match was found are returned. Alternatively, a named list can be used to look for an exact match in a specific column (see Details section)

Usage

search_networks(query, verbose = TRUE, ...)

search_networks_sf(query_sf, verbose = TRUE, ...)

Arguments

query

either a character string including a single keyword or a named list containing a custom query (see details section below), or a spatial object (see the description of query_sf). Note that if an empty character string is passed, then all datasets available are returned.

verbose

a logical. Should extra information be reported on progress?

...

further arguments to be passed to httr::GET().

query_sf

a spatial object of class sf used to search in a specific geographical area.

Value

An object of class mgSearchNetworks, which is a data.frame object with all networks informations

Details

Names of the list should match one of the column names within the table. For the networks table, those are

  • id: unique identifier of the network;

  • all_interactions: false interaction can be considered as real false interaction

  • dataset_id: the identifier of the dataset;

  • public: network publicly available;

Note that for lists with more than one element, only the first element is used, the others are ignored. An example is provided below.

Functions

  • search_networks_sf(): Search networks within a spatial object passed as an argument. Note that sf must be installed to use this function.

Examples

# \donttest{
mg_insect <- search_networks(query = "insect%")
#> Data retrieval 100%   

#>                                                                              

#> Found 14 networks
# Retrieve the search results
nets_insect <- get_collection(mg_insect)
#> Processing id: 18 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 4 	1/1  

#>                                                                              

#> Processing id: 4 	1/1  

#>                                                                              

#> Processing id: 909 	1/1  

#>                                                                              

#> Data retrieval 50%   

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 33.3%   

#> Data retrieval 66.7%   

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 9 	1/1  

#>                                                                              

#> Processing id: 9 	1/1  

#>                                                                              

#> Processing id: 948 	1/1  

#>                                                                              

#> Data retrieval 20%   

#> Data retrieval 40%   

#> Data retrieval 60%   

#> Data retrieval 80%   

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 11.1%   

#> Data retrieval 22.2%   

#> Data retrieval 33.3%   

#> Data retrieval 44.4%   

#> Data retrieval 55.6%   

#> Data retrieval 66.7%   

#> Data retrieval 77.8%   

#> Data retrieval 88.9%   

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 66 	1/1  

#>                                                                              

#> Processing id: 65 	1/1  

#>                                                                              

#> Processing id: 1460 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 91 	1/1  

#>                                                                              

#> Processing id: 90 	1/1  

#>                                                                              

#> Processing id: 1461 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 50%   

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 91 	1/1  

#>                                                                              

#> Processing id: 90 	1/1  

#>                                                                              

#> Processing id: 1471 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 99 	1/1  

#>                                                                              

#> Processing id: 98 	1/1  

#>                                                                              

#> Processing id: 1493 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 114 	1/1  

#>                                                                              

#> Processing id: 113 	1/1  

#>                                                                              

#> Processing id: 1501 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 118 	1/1  

#>                                                                              

#> Processing id: 117 	1/1  

#>                                                                              

#> Processing id: 1500 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 118 	1/1  

#>                                                                              

#> Processing id: 117 	1/1  

#>                                                                              

#> Processing id: 1502 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 119 	1/1  

#>                                                                              

#> Processing id: 118 	1/1  

#>                                                                              

#> Processing id: 1507 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 124 	1/1  

#>                                                                              

#> Processing id: 123 	1/1  

#>                                                                              

#> Processing id: 1508 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 50%   

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 124 	1/1  

#>                                                                              

#> Processing id: 123 	1/1  

#>                                                                              

#> Processing id: 1510 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 126 	1/1  

#>                                                                              

#> Processing id: 125 	1/1  

#>                                                                              

#> Processing id: 1566 	1/1  

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Data retrieval 100%   

#>                                                                              

#> Processing id: 154 	1/1  

#>                                                                              

#> Processing id: 151 	1/1  

#>                                                                              

# Spatial query
if (requireNamespace("sf", quietly = TRUE)) {
 area <- sf::st_read(system.file("shape/nc.shp", package="sf"))
 networks_in_area <- search_networks_sf(area, verbose = FALSE)
 plot(networks_in_area)
} else warning("Package sf is missing")
#> Reading layer `nc' from data source 
#>   `/usr/local/lib/R/site-library/sf/shape/nc.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> Geodetic CRS:  NAD27

# Retrieve network ID 5013
net_5013 <- search_networks(query = list(id = 5013))
#> Data retrieval 100%   

#>                                                                              

#> Found 1 networks
# Network(s) of dataset ID 19
mg_19 <- search_networks(list(dataset_id = 19))
#> Data retrieval 100%   

#>                                                                              

#> Found 1 networks
# }