Convert station names or trip codes to three-letter station codes. Useful for standardising location identifiers in datasets that use full names or for extracting station information from trip codes.
pr_add_StationCode(df)A dataframe with a new StationCode column
The function converts full names to three-letter codes:
"Darwin" → DAR
"Yongala" → YON
"North Stradbroke Island" or "North Stradbroke" → NSI
"Port Hacking" → PHB
"Maria Island" → MAI
"Kangaroo Island" → KAI
"Esperance" → ESP
"Rottnest Island" → ROT
"Ningaloo" → NIN
"Bonney Coast" → VBM
"Southern Ocean Time Series" → SOTS
pr_add_StationName() for the reverse conversion
pr_get_info() for station metadata
pr_get_trips() which returns data with trip codes
# Add station codes from station names
df <- data.frame(StationName = c("Port Hacking", "Maria Island")) %>%
pr_add_StationCode()
# Extract station codes from trip codes
df <- data.frame(TripCode = c("PHB20220101", "MAI20220115")) %>%
pr_add_StationCode()