如何将大数据表的列重命名为日期
我正在从NC文件工作,然后将数据提取到矩阵后,时间变量是列变量,为此,它在数据集的时间范围内给了它数字1:2087。我想将其重命名到应该将其重命名(从1981/12/31到2021/12/31,每列是一周的时间)我尝试通过使用
colnames(tmp_mat) <- rep(seq(as.Date('1982-01-05'), as.Date('2021-12-28'), by = 'weeks'))
此更改的列名来更改名称,但它更改了它达到数字(自1971/01/01以来的该日期的天数。 有人对如何进行这项工作有任何建议吗
I am working from an nc file and after extracting the data to a matrix the time variable is the column variable for this it just gave it a number 1:2087 for the range of time for the dataset. I would like to rename it to the date that they should be (starting at 1981/12/31 to 2021/12/31 where each column is a week) I tried to change the names by using
colnames(tmp_mat) <- rep(seq(as.Date('1982-01-05'), as.Date('2021-12-28'), by = 'weeks'))
this changed the column names but it changed it to a number (the number of days for that date since 1971/01/01.
Does anyone have any suggestions in how to make this work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的数据是矩阵,您必须将其更改为
data.frame
然后应用您的代码Your data is a matrix , you have to change it to
data.frame
then apply your code