<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Hi all,</div>
<div><br>
</div>
<div>I'm having problem with some code I hope you can help illuminate:</div>
<div><br>
</div>
<div>I've written some code originally to speed up and R function, but now really for my own education:</div>
<div><br>
</div>
<div>It's supposed to remove all columns of a matrix containing identical values ( a big one!):</div>
<div><br>
</div>
<div>
<div>#include <Rcpp.h></div>
<div>#include <vector></div>
<div><br>
</div>
<div>using namespace Rcpp;</div>
<div><br>
</div>
<div>// [[Rcpp::export]]</div>
<div>CharacterMatrix reduce_sequences(CharacterMatrix completeDNA)</div>
<div>{</div>
<div>  std::vector<int> informativeSites;          // Start vector to record informative sites I.e columns which are not all identical…</div>
<div>  for(int i = 0; i < completeDNA.ncol(); i++)      // For each column of the matrix…</div>
<div>  {</div>
<div>    CharacterVector bpsite(completeDNA.nrow());     //Make a vector to contain the column.</div>
<div>    for(int n = 0; n < completeDNA.nrow(); n++)</div>
<div>    {</div>
<div>      bpsite[n] = completeDNA(n,i);  // Fill in the vector with the matrix column.</div>
<div>    }</div>
<div>    if(any(bpsite != bpsite[0])) informativeSites.push_back(i);     //If values are not all identical, push the column index onto the vector.</div>
<div>  }</div>
<div>  </div>
<div>  CharacterMatrix cutDNA(3, informativeSites.size());     //Make new matrix to contain only all the columns which are not identical.</div>
<div>  for(int i = 0; i < informativeSites.size(); i++)</div>
<div>  {</div>
<div>    for(int n = 0; n < cutDNA.nrow(); n++)</div>
<div>    {</div>
<div>      cutDNA(n,i) = completeDNA(n,informativeSites[i]);    // Use loops to fill in the new matrix. </div>
<div>    }</div>
<div>  }</div>
<div>  return cutDNA;     //Return the new matrix</div>
<div>}</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>However I seem to be having issues with the line:</div>
<div>if(any(bpsite != bpsite[0])) informativeSites.push_back(i);</div>
<div><br>
</div>
<div>I think it is to do with the any() function, the errors are reported from the header file "SingleLogicalResult.h" and involve contorting bool. At least that's as far as I can dechiper the errors.</div>
<div><br>
</div>
<div>The console output below for full details. Is there a way for me to fix this?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Ben W.</div>
<div><br>
</div>
<div>
<div>> Rcpp::sourceCpp('reduceseq.cpp')</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/logical/SingleLogicalResult.h: In instantiation of ‘Rcpp::sugar::conversion_to_bool_is_forbidden<false>’:</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/logical/SingleLogicalResult.h:74:   instantiated from ‘Rcpp::sugar::SingleLogicalResult<NA, T>::operator bool() [with bool NA = true, T = Rcpp::sugar::Any<true, Rcpp::sugar::Comparator_With_One_Value<16,
 Rcpp::sugar::not_equal<16>, true, Rcpp::Vector<16> > >]’</div>
<div>reduceseq.cpp:17:   instantiated from here</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/logical/SingleLogicalResult.h:36: error: invalid use of incomplete type ‘struct Rcpp::sugar::forbidden_conversion<false>’</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/logical/SingleLogicalResult.h:29: error: declaration of ‘struct Rcpp::sugar::forbidden_conversion<false>’</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h: In member function ‘int Rcpp::sugar::Comparator_With_One_Value<RTYPE, Operator, NA, T>::rhs_is_not_na(int) const [with int RTYPE
 = 16, Operator = Rcpp::sugar::not_equal<16>, bool NA = true, T = Rcpp::Vector<16>]’:</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h:38:   instantiated from ‘Rcpp::sugar::Comparator_With_One_Value<RTYPE, Operator, NA, T>::Comparator_With_One_Value(const Rcpp::VectorBase<RTYPE,
 LHS_NA, LHS_T>&, typename Rcpp::traits::storage_type<RTYPE>::type) [with int RTYPE = 16, Operator = Rcpp::sugar::not_equal<16>, bool NA = true, T = Rcpp::Vector<16>]’</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/logical_operators__Vector__primitive.h:266:   instantiated from ‘Rcpp::sugar::Comparator_With_One_Value<RTYPE, Rcpp::sugar::not_equal<RTYPE>, NA, T> operator!=(const
 Rcpp::VectorBase<RTYPE, NA, VECTOR>&, typename Rcpp::traits::storage_type<RTYPE>::type) [with int RTYPE = 16, bool NA = true, T = Rcpp::Vector<16>]’</div>
<div>reduceseq.cpp:17:   instantiated from here</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h:59: error: operands to ?: have different types ‘SEXPREC*’ and ‘int’</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h: In member function ‘int Rcpp::sugar::Comparator_With_One_Value<RTYPE, Operator, NA, T>::rhs_is_na(int) const [with int RTYPE
 = 16, Operator = Rcpp::sugar::not_equal<16>, bool NA = true, T = Rcpp::Vector<16>]’:</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h:38:   instantiated from ‘Rcpp::sugar::Comparator_With_One_Value<RTYPE, Operator, NA, T>::Comparator_With_One_Value(const Rcpp::VectorBase<RTYPE,
 LHS_NA, LHS_T>&, typename Rcpp::traits::storage_type<RTYPE>::type) [with int RTYPE = 16, Operator = Rcpp::sugar::not_equal<16>, bool NA = true, T = Rcpp::Vector<16>]’</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/logical_operators__Vector__primitive.h:266:   instantiated from ‘Rcpp::sugar::Comparator_With_One_Value<RTYPE, Rcpp::sugar::not_equal<RTYPE>, NA, T> operator!=(const
 Rcpp::VectorBase<RTYPE, NA, VECTOR>&, typename Rcpp::traits::storage_type<RTYPE>::type) [with int RTYPE = 16, bool NA = true, T = Rcpp::Vector<16>]’</div>
<div>reduceseq.cpp:17:   instantiated from here</div>
<div>/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h:56: error: invalid conversion from ‘SEXPREC* const’ to ‘int’</div>
<div>make: *** [reduceseq.o] Error 1</div>
<div>g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -I/usr/local/include  -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"    -fPIC  -g
 -O2  -c reduceseq.cpp -o reduceseq.o </div>
</div>
</body>
</html>