data.frame
에서 날짜 정보가 들어있는 벡터를 추출하고 하위 세트로 만들려고합니다. DataFrame
에서 DateVector
을 성공적으로 추출 할 수 있습니다. 그러나 데이터를 부분 집합하려고 할 때 오류가 발생합니다.DateVector의 서브 세트
서브 세트 주위에 /* */
이 주어진다면 아래 내용이 정상적으로 작동합니다.
error: invalid user-defined conversion from 'Rcpp::LogicalVector {aka Rcpp::Vector<10, Rcpp::PreserveStorage>}' to 'int' [-fpermissive]
Rcpp::DateVector StDate_sub = StDate[ind]
두 번째는 다음과 같습니다 : 나는이 문서에서 보았지만 방법을 찾을 수 없습니다
no known conversion from 'SEXP' to 'int' file585c1863151c.cpp:23:53: error: conversion from 'Rcpp::Date' to non-scalar type 'Rcpp::DateVector {aka Rcpp::oldDateVector}' requested
Rcpp::DateVector EtDate_sub = EtDate[ind];
Rcpp::cppFunction('
Rcpp::DataFrame test(DataFrame x, StringVector y) {
StringVector New = x["string_1"];
std::string KEY = Rcpp::as<std::string>(y[0]);
Rcpp::LogicalVector ind(New.size());
for(int i = 0; i < New.size(); i++){
ind[i] = (New[i] == KEY);
}
Rcpp::StringVector st1 = x["string_1"];
Rcpp::StringVector Id = x["ID"];
Rcpp::StringVector NameId = x["NameID"];
Rcpp::DateVector StDate = x["StartDate"];
Rcpp::DateVector EtDate = x["EndDate"];
/*
Rcpp::DateVector StDate_sub = StDate[ind];
Rcpp::DateVector EtDate_sub = EtDate[ind];
*/
return Rcpp::DataFrame::create(Rcpp::Named("string_1") = st1[ind],
Rcpp::Named("ID") = Id[ind],
Rcpp::Named("NameID") = NameId[ind]/*,
Rcpp::Named("StartDate") = StDate_sub,
Rcpp::Named("EndDate") = EtDate_sub*/
);
}')
내가받는 두 가지 주목할만한 오류가 있습니다. 미안, 내가 놓친거야. data.frame
에 몇 가지 날짜 변수가 있습니다. 중첩 된 for 루프에서 데이터 집합의 하위 집합으로 Rcpp를 사용하고 있습니다. 현재 너무 많은 시간이 걸립니다. 서브셋 데이터 세트가 일부 처리 과정에서 필요하므로 data.table
또는 dplyr
에 구현할 수 없습니다.
하위 집합 연산자 구현은 새롭고 오래된'DateVector' 구현 모두에서 문제가되는 것처럼 보입니다. / – coatless