Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

roman2int

Convert Roman Numerals to Integers


Description

Convert roman numerals to integers

Usage

roman2int(roman)

Arguments

roman

character vector containing roman numerals

Details

This function will convert roman numerals to integers without the upper bound imposed by R (3899), ignoring case.

Value

A integer vector with the same length as roman. Character strings which are not valid roman numerals will be converted to NA.

Author(s)

Gregory R. Warnes greg@warnes.net

See Also

Examples

roman2int( c('I', 'V', 'X', 'C', 'L', 'D', 'M' )  )

# works regardless of case
roman2int( 'MMXVI' )
roman2int( 'mmxvi' )

# works beyond R's limit of 3899
val.3899 <- 'MMMDCCCXCIX'
val.3900 <- 'MMMCM'
val.4000 <- 'MMMM'
as.numeric(as.roman( val.3899 ))
as.numeric(as.roman( val.3900 ))
as.numeric(as.roman( val.4000 ))

roman2int(val.3899)
roman2int(val.3900)
roman2int(val.4000)

gtools

Various R Programming Tools

v3.8.2
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, and Thomas Lumley
Initial release
2020-03-23

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.