data(sparrowSiteData)
data(sparrowDetectionData)
sparrowDf <- RdistDf( sparrowSiteData, sparrowDetectionData )
is.RdistDf(sparrowDf, verbose = T)
summary(sparrowDf)
summary(sparrowDf
, formula = dist ~ groupsize(groupsize)
, w.hi = units::set_units(100, "m"))
# Equivalent to above:
sparrowDf <- sparrowDetectionData |>
dplyr::nest_by( siteID
, .key = "detections") |>
dplyr::right_join(sparrowSiteData, by = "siteID")
attr(sparrowDf, "detectionColumn") <- "detections"
attr(sparrowDf, "effortColumn") <- "length"
attr(sparrowDf, "obsType") <- "single"
attr(sparrowDf, "transType") <- "line"
is.RdistDf(sparrowDf, verbose = T)
summary(sparrowDf, formula = dist ~ groupsize(groupsize))
# Condensed view: 1 row per transect (make sure tibble is attached)
sparrowDf
# Expansion methods:
# (1) use Rdistance::unnest (includes zero transects)
df1 <- unnest(sparrowDf)
any( df1$siteID == "B2" ) # TRUE
# Use tidyr::unnest(); but, no zero transects
df2 <- tidyr::unnest(sparrowDf, cols = "detections")
any( df2$siteID == "B2" ) # FALSE
# Use dplyr::reframe for specific transects (e.g., for transect "B3")
sparrowDf |>
dplyr::filter(siteID == "B3") |>
dplyr::reframe(detections)
# Count detections per transect (can't use dplyr::if_else)
df3 <- sparrowDf |>
dplyr::reframe(nDetections = ifelse(is.null(detections), 0, nrow(detections)))
sum(df3$nDetections) # Number of detections
sum(df3$nDetections == 0) # Number of zero transects
# Point transects
data(thrasherDetectionData)
data(thrasherSiteData)
thrasherDf <- RdistDf( thrasherSiteData
, thrasherDetectionData
, pointSurvey = TRUE
, by = "siteID"
, .detectionCol = "detections")
summary(thrasherDf, formula = dist ~ groupsize(groupsize))
Run the code above in your browser using DataLab