Get CRS code from a string with the station name.

get_crs(station, ...)

Arguments

station

String with the station name, partial names are allowed.

...

Arguments passed on to base::grep

ignore.case

if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

perl

logical. Should Perl-compatible regexps be used?

value

if FALSE, a vector containing the (integer) indices of the matches determined by grep is returned, and if TRUE, a vector containing the matching elements themselves is returned.

fixed

logical. If TRUE, pattern is a string to be matched as is. Overrides all conflicting arguments.

useBytes

logical. If TRUE the matching is done byte-by-byte rather than character-by-character. See ‘Details’.

invert

logical. If TRUE return indices or values for elements that do not match.

Value

Vector of strings with the matched CRS codes, or NULL if no match is found.

Examples

trainR::get_crs("London")
#> The following stations were found: #> - Hampton (London) [HMP] #> - Lee (London) [LEE] #> - London Blackfriars [BFR] #> - London Bridge [LBG] #> - London Cannon Street [CST] #> - London Charing Cross [CHX] #> - London Euston [EUS] #> - London Fenchurch Street [FST] #> - London Fields [LOF] #> - London Kings Cross [KGX] #> - London Liverpool Street [LST] #> - London Marylebone [MYB] #> - London Paddington [PAD] #> - London Road (Brighton) [LRB] #> - London Road (Guildford) [LRD] #> - London St Pancras (Intl) [SPX] #> - London St Pancras International [STP] #> - London Victoria [VIC] #> - London Waterloo [WAT] #> - London Waterloo East [WAE] #> - Queens Park (London) [QPW] #> - Richmond (London) [RMD] #> - St Johns (London) [SAJ] #> - St Margarets (London) [SMG] #> - Stratford (London) [SRA] #> - Streatham (Greater London) [STE] #> - Sydenham (London) [SYD] #> - Whitton (London) [WTN]
trainR::get_crs("Manchester")
#> The following stations were found: #> - Burnley Manchester Road [BYM] #> - Castleton (Manchester) [CAS] #> - Clifton (Manchester) [CLI] #> - Eccles (Manchester) [ECC] #> - Hale (Manchester) [HAL] #> - Ince (Manchester) [INC] #> - Kearsley (Manchester) [KSL] #> - Manchester Airport [MIA] #> - Manchester Oxford Road [MCO] #> - Manchester Piccadilly [MAN] #> - Manchester United Football Ground [MUF] #> - Manchester Victoria [MCV] #> - Mills Hill (Manchester) [MIH] #> - Mossley (Manchester) [MSL] #> - Swinton (Manchester) [SNN]
trainR::get_crs("manchester", ignore.case = TRUE)
#> The following stations were found: #> - Burnley Manchester Road [BYM] #> - Castleton (Manchester) [CAS] #> - Clifton (Manchester) [CLI] #> - Eccles (Manchester) [ECC] #> - Hale (Manchester) [HAL] #> - Ince (Manchester) [INC] #> - Kearsley (Manchester) [KSL] #> - Manchester Airport [MIA] #> - Manchester Oxford Road [MCO] #> - Manchester Piccadilly [MAN] #> - Manchester United Football Ground [MUF] #> - Manchester Victoria [MCV] #> - Mills Hill (Manchester) [MIH] #> - Mossley (Manchester) [MSL] #> - Swinton (Manchester) [SNN]