select_related_resourcesR Documentation

For a given Heritage Place, find all Connected Components, select the components have a given value in a certain field

Description

For a given Heritage Place, find all Connected Components (ex: a Built Component) having a a given value (ex: "Stable") in a certain field (ex: "Measurement Number"). This function is run after 'list_related_resources()'.

Usage

select_related_resources(
  db.con = NA,
  df = NA,
  having = "Stable",
  measure = "Measurement Number",
  disconn = TRUE,
  verbose = TRUE
)

Arguments

db.con

a 'dbConnect' connection to the database.

df

a dataframe resultion from the 'list_related_resources()' function, having the UUID of Connected Component

having

a vector of values to only keep CC having these values. By default c("Stable"). These values must appear in the 'ids.csv' file with their 'valueid' (see 'python manage.py whatisthis').

measure

the name of the field where the value of 'having' is recorded. By default "Measurement Number".

disconn

if TRUE (by defalut), will disconnect from the DB.

verbose

if TRUE (by default), print messages.

Value

A dataframe recordind the IDs and UUIDs of the Heritage Place and Connected Components with, for the latter, the selected fields

Examples


d <- hash::hash()
my_con <- RPostgres::dbConnect(drv = RPostgres::Postgres(),
                               user = 'xxx',
                               password = 'xxx',
                               dbname = 'eamena',
                               host = 'ec2-54-155-109-226.eu-west-1.compute.amazonaws.com',
                               port = 5432)

df <- list_related_resources(db.con = my_con,
                             d = d,
                             id = "EAMENA-0164943",
                             disconn = F)

# get the number of 'Stable' (by default)
df.measures <- select_related_resources(db.con = my_con,
                                        df = df)
df.measures
##            hp.id                              hp.uuid             cc.id                              cc.uuid cc.type
## 1 EAMENA-0164943 d4feb830-10c7-4d80-a19e-e608f424be4c COMPONENT-0000141 90400bb6-ff54-4afd-8183-65c67fa97448  Stable
## Measurement.Number
## 1                 30

# get the number of 'Rooms'
df.measures <- select_related_resources(db.con = my_con,
                                        having = c("Room"),
                                        df = df)
df.measures
##             hp.id                              hp.uuid             cc.id                              cc.uuid cc.type cc.measure
## 1 EAMENA-0164943 d4feb830-10c7-4d80-a19e-e608f424be4c COMPONENT-0000144 28af281c-e4b9-44ac-aa98-2608581b7540    Room         28