R has two built-in constants that might help: state.abb
with the abbreviations, and state.name
with the full names. Here is a simple usage example:
> x <- c("New York", "Virginia")
> state.abb[match(x,state.name)]
[1] "NY" "VA"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…