sum_distinct_vessels {icesVMS} | R Documentation |
Add together anonymous ID entries
Description
Anonymous vessel IDs are supplied when there are less than 2 vessels. Therefore when adding these values, if there is one or more values containing an empty string (? 2 vessels) then the results is an empty string also. Otherwise, a unique vector of vessel IDs is computed and if there are 2 or less unique entries they are returned, otherwise an empty string is returned.
Usage
sum_distinct_vessels(id, n)
sum_vessel_ids(id, n)
Arguments
id |
a vector vessel Ids entries: string vector of semi-colon separated IDs |
n |
a vector corresponding to the number of unique vessel ids in the vector
supplied in |
Value
a single character
Note
the format of the vessel IDs is a semi-colon separated list of IDs contained in a character vector of length one.
Examples
sum_vessel_ids(c("id1;id2", "id1", "id2", "id1;id3", ""), c(2, 1, 1, 2, 3))
sum_vessel_ids(c("id1;id2", "id1", "id2", "id1;id3"), c(2, 1, 1, 2))
sum_distinct_vessels(c("id1;id2", "id1", "id2", "id1;id3", ""), c(2, 1, 1, 2, 3))
sum_distinct_vessels(c("id1;id2", "id1", "id2", "id1;id3"), c(2, 1, 1, 2))
## Not run:
require(dplyr)
data(vms)
vms <-
vms %>%
group_by(year, cSquare) %>%
summarise(
fishingHours = sum(fishingHours, na.rm = TRUE),
totweight = sum(totweight, na.rm = TRUE),
noDistinctVessels = sum_distinct_vessels(anonymizedVesselID, noDistinctVessels),
anonymizedVesselID = sum_vessel_ids(anonymizedVesselID, noDistinctVessels),
.groups = "drop"
)
## End(Not run)
[Package icesVMS version 1.1.4 Index]