how to extract the 2nd number in a string

Viewed 50

I want to extract only the second number (in order) from a string.

string = "vancomycin 1G IV 3 times a day over 1 hour."

desired output = 3

1 Answers

A posssible solution, but not the prettiest one

str_extract_all(string, "\\d+")[[1]][2]
Related