Split string in characters and numbers


China 91 km  91
Iran 921 km 921
Pakistan 2,670 km
Tajikistan 1,357 km
Turkmenistan 804 km
Uzbekistan 144 km

I want the information of the numeric border length in a new columns. Solution via stringr library

# extract the numbers and create new variable named new_var
df$new_var <- as.numeric(str_extract(df$column_to_split, "[0-9]+"))

extract the characters and create new variable named country
df$country <- (str\_extract(df$column\_to_split, "[aA-zZ]+"))</code>