get_data_as_Matrix
C++ Function Reference
1 Signature
std::vector< double > BigDataStatMeth::get_data_as_Matrix(std::vector< std::string > strBlockValues)2 Description
Converts a vector of string values to numeric (double) values.
3 Parameters
strBlockValues(std::vector< std::string >): Vector of strings to convert
4 Returns
std::vector
5 Details
strBlockValuesVector of strings to convert std::vector
6 Caller Graph
7 Source Code
NoteImplementation
File: inst/include/hdf5Utilities/hdf5ImportFiles.hpp • Lines 131-151
inline std::vector<double> get_data_as_Matrix(std::vector<std::string> strBlockValues)
{
std::vector<double> doubleVector(strBlockValues.size());
std::transform(strBlockValues.begin(), strBlockValues.end(), doubleVector.begin(), [](const std::string& s) mutable
{
if( is_number(s) ==1 ){
return (std::stod(s));
} else {
// Takes in to account the possible eol for the last column
if( is_number(s.substr(0,s.length()-1) ) ==1 ){
return (std::stod(s));
} else {
Rcpp::stop("Error: Column is not numeric. Only numeric data is allowed. Maybe there is a blank row at the end of the file or any field is empty");
}
}
});
return(doubleVector);
}8 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = get_data_as_Matrix(...);