Skip to content

Commit

Permalink
strr_ghost error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dwachsmuth committed Jun 9, 2024
1 parent f12b709 commit d1efe11
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions R/strr_ghost.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,6 @@ strr_ghost <- function(
created = {{created}},
scraped = {{scraped}})

# Check for multiple property_IDs
if (nrow(dplyr::filter(
property, dplyr::n() > 1, .by = property_ID)) > 0) stop(
"Multiple rows detected for a single property_ID", call. = FALSE)

# Check for multiple host_IDs for one property_ID
if (nrow(dplyr::filter(
property, length(unique(host_ID)) > 1,
.by = property_ID)) > 0) stop(
"Multiple host_IDs detected for a single property_ID", call. = FALSE)

if (lt_flag) property <-
dplyr::rename(property, listing_type = {{listing_type}})

Expand All @@ -264,6 +253,17 @@ strr_ghost <- function(
property <- property[listing_type == private_room]
}

# Check for multiple property_IDs
if (nrow(dplyr::filter(
property, dplyr::n() > 1, .by = property_ID)) > 0) stop(
"Multiple rows detected for a single property_ID", call. = FALSE)

# Check for multiple host_IDs for one property_ID
if (nrow(dplyr::filter(
property, length(unique(host_ID)) > 1,
.by = property_ID)) > 0) stop(
"Multiple host_IDs detected for a single property_ID", call. = FALSE)

# Filter property to clusters >= min_listings, and nest by host_ID
property <-
property[, if (.N >= min_listings) list(data = list(.SD)), by = "host_ID"]
Expand Down

0 comments on commit d1efe11

Please sign in to comment.