Learn R Programming

pleiades (version 0.3.0)

pl_search: Search for a place, name or location.

Description

This function searches a locally created SQLite database created from csv files.

Usage

pl_search(query = NULL, ...)

pl_search_loc(query = NULL, ...)

pl_search_names(query = NULL, ...)

pl_search_places(query = NULL, ...)

Arguments

query

A place ID. If left NULL, returns the table, which is of class tbl, which can then be passed on to other dplyr functions.

...

Further args passed on to dplyr::tbl()

Details

On the first query if not run before, the function takes a bit to get the raw data (if not already gotten), temporarily load the raw csv data, then create a SQLite database, and create the pointer to it. Subsequent calls should be very fast.

There is a function pl_cache, used to download the raw csv files. That function is run internally in these functions if you have not run it before, or if only some fo the files are present.

Examples

Run this code
# NOT RUN {
pl_search()
pl_search_loc()
pl_search_names()
pl_search_places()

pl_search_loc("SELECT * FROM locations limit 5")
pl_search_names("SELECT * FROM names limit 5")
pl_search_places("SELECT * FROM places limit 5")

library(dplyr)
locs <- pl_search("SELECT * FROM locations limit 1000") %>%
  select(pid, reprLat, reprLong)
nms <- pl_search("SELECT * FROM names limit 1000") %>% select(pid)
left_join(locs, nms, "pid", copy = TRUE) %>% collect %>% NROW
# }

Run the code above in your browser using DataLab