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

getNumbers

Extract numbers from (BayesX log file) strings


Description

This is an internal helper function for extractSamples which extracts numbers from (BayesX log file) strings.

Usage

getNumbers(beforeStringsList, stringVector)

Arguments

beforeStringsList

The list with the strings standing before the numbers which shall be extracted.

stringVector

The vector of strings to be searched for the numbers.

Value

Returns a list with the extracted numbers.

Author(s)

Daniel Sabanes Bove

Examples

## create a nice example
sampleStrings <- c("Second: 385",
                   "  First:  70000 ",                   
                   "asdfkf T: 24      ")

## test the function
extractedNumbers <- BayesX:::getNumbers(beforeStringsList=
                                        list(first="First:",
                                             second="Second:",
                                             third="T:"),
                                        stringVector=sampleStrings)

## and assert that the result is as expected
stopifnot(identical(extractedNumbers,
                    list(first=70000, second=385, third=24)))

## specific test
stopifnot(identical(BayesX:::getNumbers(beforeStringsList=
                                        list(Iterations = "Number of iterations:"),
                                        stringVector=
                                        "  Number of iterations: 70000 "),
                    list(Iterations=70000)))

BayesX

R Utilities Accompanying the Software Package BayesX

v0.3-1
GPL-2 | GPL-3
Authors
Nikolaus Umlauf [aut, cre], Thomas Kneib [aut], Nadja Klein [aut], Felix Heinzl [ctb], Andreas Brezger [ctb], Daniel Sabanes Bove [ctb]
Initial release
2019-08-23

We don't support your browser anymore

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