unnest function

unnest - Unnest an RdistDf data frame

unnest - Unnest an RdistDf data frame

Unnest an RdistDf data frame by expanding the embedded 'detections' column. This unnest includes the so-called zero transects (transects without detections).

unnest(data, ...)

Arguments

  • data: An RdistDf data frame. RdistDf data frames contain one line per transect and a list-based column. The list-based column contains a data frame with detection information. The detection information data frame on each row contains (at least) distances and group sizes of all targets detected on the transect. Function RdistDf creates RdistDf data frames from separate transect and detection data frames. is.RdistDf checks whether data frames are RdistDf's.
  • ...: Additional arguments passed to tidyr::unnest if data is not an RdistDf.

Returns

An expanded data frame, without embedded data frames. Rows in the return represent with one detection or one transect. If multiple detections were made on one transect, the transect will appear on multiple rows. If no detections were made on a transect, it will appear on one row with NA detection distance.

Examples

data('sparrowDf') # tidyr::unnest() does not include zero transects detectionDf <- tidyr::unnest(sparrowDf, detections) nrow(detectionDf) any(detectionDf$siteID == "B2") # Rdistance::unnest() includes zero transects fullDf <- unnest(sparrowDf) nrow(fullDf) any(fullDf$siteID == "B2")
  • Maintainer: Trent McDonald
  • License: GNU General Public License
  • Last published: 2025-04-10