在一个xts对象中的第N个日子

编程入门 行业动态 更新时间:2024-10-19 12:47:44
本文介绍了在一个xts对象中的第N个日子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

价格是一个xts对象

period.ends = endpoints(prices, 'months',k=1)

与这一行我找到一个月的最后一天的位置在一个时间序列。

with this line i find position of the last day of the month in a time series.

如何找到月的第一天的位置(不总是1个月)?第二天?

How to find position of the first day of month (not always 1 of the month)? And the second day?

谢谢

推荐答案

startpoints <- function (x, on = "months", k = 1) { head(endpoints(x, on, k) + 1, -1) } period.starts = startpoints(prices, 'months', k=1)

另请参见: xts ::: startof 和 xts :: firstof

更多推荐

在一个xts对象中的第N个日子

本文发布于:2023-11-30 04:22:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648707.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:象中   日子   xts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!