本文整理汇总了C++中StringVector::attr方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVector::attr方法的具体用法?C++ StringVector::attr怎么用?C++ StringVector::attr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVector
的用法示例。
在下文中一共展示了StringVector::attr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pairwiseDistRcpp
// pairwiseDist
// [[Rcpp::export]]
NumericMatrix pairwiseDistRcpp (StringVector seq, NumericMatrix dist_mat) {
// allocate the matrix we will return
NumericMatrix rmat(seq.length(), seq.length());
for (int i = 0; i < rmat.nrow(); i++) {
for (int j = 0; j < i; j++) {
// check seq equal
std::string row_seq = as<std::string>(seq[i]);
std::string col_seq = as<std::string>(seq[j]);
double distance = seqDistRcpp(row_seq, col_seq, dist_mat);
// write to output matrix
rmat(i,j) = distance;
rmat(j,i) = distance;
}
}
// Add row and column names
Rcpp::List dimnames = Rcpp::List::create(seq.attr("names"),
seq.attr("names"));
rmat.attr("dimnames") = dimnames;
return rmat;
}
示例2: pairwiseEqual
//' Calculate pairwise equivalence between sequences
//'
//' \code{pairwiseEqual} determined pairwise equivalence between a pairs in a
//' set of sequences, excluding ambiguous positions (Ns and gaps).
//'
//' @param seq character vector containing a DNA sequences.
//'
//' @return A logical matrix of equivalence between each entry in \code{seq}.
//' Values are \code{TRUE} when sequences are equivalent and \code{FALSE}
//' when they are not.
//'
//' @seealso Uses \link{seqEqual} for testing equivalence between pairs.
//' See \link{pairwiseDist} for generating a sequence distance matrix.
//'
//' @examples
//' # Gaps and Ns will match any character
//' seq <- c(A="ATGGC", B="ATGGG", C="ATGGG", D="AT--C", E="NTGGG")
//' d <- pairwiseEqual(seq)
//' rownames(d) <- colnames(d) <- seq
//' d
//'
//' @export
// [[Rcpp::export]]
LogicalMatrix pairwiseEqual (StringVector seq) {
// allocate the matrix we will return
LogicalMatrix rmat(seq.length(), seq.length());
for (int i = 0; i < rmat.nrow(); i++) {
for (int j = 0; j <= i; j++) {
// check seq equal
std::string row_seq = as<std::string>(seq[i]);
std::string col_seq = as<std::string>(seq[j]);
bool is_equal = seqEqual(row_seq, col_seq);
// write to output matrix
rmat(i,j) = is_equal;
rmat(j,i) = is_equal;
}
}
// Add row and column names
Rcpp::List dimnames = Rcpp::List::create(seq.attr("names"),
seq.attr("names"));
rmat.attr("dimnames") = dimnames;
return rmat;
}