Rcpp 调试 - 致命错误:Datetime.h:没有这样的文件或目录; xtsAPI.h:没有这样的文件或目录

2024-04-26

我正在使用 Rcpp 来处理 Datetime 和 xts 数据。但是,我收到错误No such file or directory以下代码的第 2 行和第 3 行均出现错误:

#include <Rcpp.h>
#include <Datetime.h>
#include <xtsAPI.h>
// [[Rcpp::depends(xts)]
using namespace Rcpp;
using namespace std;

这是我收到的错误:

fatal error: Datetime.h: No such file or directory; 
fatal error: xtsAPI.h: No such file or directory;

Use #include <Rcpp/Datetime.h>代替#include <Datetime.h>并确保RcppXts已安装 - 那么您应该能够使用这两个库:

if(!"RcppXts" %in% installed.packages()[,1]) {
  install.packages("RcppXts")
}

#include <Rcpp.h>
#include <Rcpp/Datetime.h>
#include <xtsAPI.h>
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(xts)]]

/*
 * http://gallery.rcpp.org/articles/accessing-xts-api/
 */

// [[Rcpp::export]]
Rcpp::NumericVector createXts(int sv, int ev) {

    Rcpp::IntegerVector ind = Rcpp::seq(sv, ev);     // values

    Rcpp::NumericVector dv(ind);               // date(time)s are real values
    dv = dv * 86400;                     // scaled to days
    dv.attr("tzone")    = "UTC";         // the index has attributes
    dv.attr("tclass")   = "Date";

    Rcpp::NumericVector xv(ind);               // data her same index
    xv.attr("dim")         = Rcpp::IntegerVector::create(ev-sv+1,1);
    xv.attr("index")       = dv;
    Rcpp::CharacterVector klass  = Rcpp::CharacterVector::create("xts", "zoo");
    xv.attr("class")       = klass;
    xv.attr(".indexCLASS") = "Date";
    xv.attr("tclass")      = "Date";
    xv.attr(".indexTZ")    = "UTC";
    xv.attr("tzone")       = "UTC";

    return xv;

}

// [[Rcpp::export]]
Rcpp::NumericVector rbindXts(Rcpp::NumericMatrix ma, Rcpp::NumericMatrix mb, bool dup=true) {
  Rcpp::NumericMatrix mc = xtsRbind(ma, mb, Rcpp::wrap(dup));
  return mc;
}


// [[Rcpp::export]]
Rcpp::LogicalVector match_date(Rcpp::Datetime d, Rcpp::DatetimeVector dv) {

  Rcpp::LogicalVector lv(dv.size());

  std::transform(dv.begin(), dv.end(), lv.begin(), 
                 [&](Rcpp::Datetime dIn) -> bool {
                   return dIn == d;
                 });
  return lv;
}

/*** R
D <- Sys.time()
Dv <- seq.POSIXt(from = D - 3600*24*3, to = D + 3600*24*3, by="day")

match_date(D, Dv)
# [1] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE

x1 <- createXts(2,5)
x2 <- createXts(4,9)

rbindXts(x1, x2)
#            [,1]
# 1970-01-03    2
# 1970-01-04    3
# 1970-01-05    4
# 1970-01-06    5
# 1970-01-07    6
# 1970-01-08    7
# 1970-01-09    8
# 1970-01-10    9
*/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Rcpp 调试 - 致命错误:Datetime.h:没有这样的文件或目录; xtsAPI.h:没有这样的文件或目录 的相关文章

随机推荐

  • Safari 扩展弹出窗口链接

    是否可以在 Safari 弹出窗口中使用链接 我已经做了我能想到的所有事情 但似乎向弹出窗口添加链接只会改变外观 并且不会导致任何可点击的内容 无论是使用 href 还是 onclick 您可以在 href 或 div 上添加 onclic
  • asp.net mvc 树路径的复杂路由

    我想知道如何定义这样的路由映射 TreePath Action Id TreeMap 是从数据库动态加载的 如下所示 Gallery GalleryA SubGalleryA View 3 您可以创建自定义路由处理程序来执行此操作 实际路线
  • 当我从 Django 应用程序“打印”它们时,它们会去哪里?

    我在 Linux 服务器上有一个 Django 应用程序 在其中一种观点中 某种形式print命令被执行 并打印一些字符串 我怎样才能知道打印的字符串是什么 是否有一些日志保存这些东西 输出应该在 django 启动的终端中 如果你不直接启
  • Cassandra 中的强一致性

    根据datastax文章 可以保证强一致性 如果 R W gt N 在哪里 R是读操作的一致性级别 W为写操作的一致性级别 N 是副本数 这里的强一致性是什么意思呢 这是否意味着 每次 从数据库给出查询响应时 响应将 始终 是最后更新的值
  • 跨 AVX 通道的最佳方式是什么?

    有些问题具有类似的标题 但我的问题涉及其他地方未涵盖的一个非常具体的用例 我有 4 个 128d 寄存器 x0 x1 x2 x3 我想将它们的内容重新组合在 5 个 256d 寄存器 y0 y1 y2 y3 y4 中 以准备其他计算 on
  • 使用 C#/C++ 托管 VST/DX 仪器? [关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我试图了解用 C 或 C 构建准系统虚拟仪器主机所需的工作量 但我无法获得任何硬信息 有人知道有什么好的
  • Pandas DataFrame MultiIndex groupby 滚动操作缺少日期

    我有一个数据框 其中有一个 MultiIndex 其中索引的最后一列是日期 我正在尝试以特定频率对列进行滚动操作 据我了解 如果我有 TimeIndex 通常的 pandas 方法是使用频率字符串调用滚动函数 例如 如果我希望窗口为两天 则
  • VB6 和 .PFX 代码签名

    我的老板已经从 Comodo 获得了证书 而我一直在努力寻找获得证书问题的解决方案intoVB6 应用程序 证书本身是 VB6 格式的 我对这类事情几乎一无所知 Comodo 的人真是太乐于助人了 我的老板说他可以在互联网上找到一些东西 显
  • 找出用于制作 JAR 的 Scala 版本

    我试图弄清楚使用哪个 Scala 版本进行编译A jar 我有两个版本 一个来自我的 ivy2 存储库 另一个来自 Maven 运行后jar xf A jar 我苦苦寻找scala and version 但什么也没发现 grep ri s
  • Mechanize 出现 SSL 错误

    我得到了这些命令irb require mechanize agent Mechanize new agent get https monabo lemonde fr customer account forgotpassword 我收到这
  • highcharts 弄错了我的时间

    highcharts 弄错了我的时间 我来自委内瑞拉 以防万一 我正在做一个实时系统 我可以在数据库中获取时间 秒和毫秒 例如 10 39 09 2 我应用 strtotime time 然后通过 json 发送到图表 在我的高图表中 我进
  • Seaborn 线图使用中位数而不是均值

    我在用着seaborn lineplot 创建像这样的线图 代表平均值的线 由代表标准差的带包围 sns lineplot x trial y rvalues hue subject err style band ci sd data df
  • 从文件中读取行,在第二个文件中 grep ,并为每个 $line 输出一个文件

    我有以下两个文件 sequences txt 158333741 Acaryochloris marina MBIC11017 uid58167 158333741 432 1 432 COG0001 0 158339504 Acaryoc
  • 如何在 spring-data-mongodb 框架中将 BigDecimal 转换为 Double

    Spring Data MongoDB 映射默认将 BigDecimal 转换为 String 但是 我希望它们在 mongodb 中转换为 Double 这是后者在 mongodb 中对该字段进行查询 比较查询 聚合查询 所必需的 我如何
  • 合并排序代码不起作用并显示异常

    public static void Merge int arr int p int q int r int n1 q p int n2 r q int L new int n1 int R new int r n2 for int i 0
  • 如何访问 Flask 路由中的查询字符串?

    如何访问 Flask 路由中的查询参数或查询字符串 从 Flask 文档来看 这一点并不明显 示例路线 data下面说明了我想要访问该数据的上下文 如果有人要求类似的东西example com data abc 123 我想访问该字符串 a
  • 如何在特定时间后从“std::cin”读取超时

    我写了一个小程序 int main int argc char argv int n std cout lt lt Before reading from cin lt lt std endl Below reading from cin
  • CUDA线程执行顺序

    我有一个 CUDA 程序的以下代码 include
  • 如何实现 Spring XD 接收器?

    到目前为止 我已经实现了 Spring XD 处理器 例如像这样 MessageEndpoint public class MyTransformer Transformer inputChannel input outputChannel
  • Rcpp 调试 - 致命错误:Datetime.h:没有这样的文件或目录; xtsAPI.h:没有这样的文件或目录

    我正在使用 Rcpp 来处理 Datetime 和 xts 数据 但是 我收到错误No such file or directory以下代码的第 2 行和第 3 行均出现错误 include