Function to extract a numeric value from a line of text.
Details
The 1-line input text is split into a character vector using [stringr::str_split_1()] and the first element of the result is retained. Whitespace preceding and following the retained text is also removed (but "interior" whitespace is retained). The result is converted to numeric using [as.numeric()].
Examples
# example code
txt = " 45.27 #--input value of interest";
extractNumericValue(txt)
#> [1] 45.27
txt = "'hows this' #--input text of interest";
extractTextValue(txt); #--returns NA
#> [1] "'hows this'"