【问题标题】:R: Unused argument error in round [closed]R:回合中未使用的参数错误[关闭]
【发布时间】:2013-06-12 14:38:25
【问题描述】:

我有一个看起来像这样的 data.frame mdf;

       date     time moon Sunrise Sunset            time.tmp
1    1.9.12  0:00:00 0.00    6:52  20:26 2013-06-12 00:00:00
2    1.9.12  1:00:00 0.00    6:52  20:26 2013-06-12 01:00:00
3    1.9.12  2:00:00 0.00    6:52  20:26 2013-06-12 02:00:00
4    1.9.12  3:00:00 0.00    6:52  20:26 2013-06-12 03:00:00
5    1.9.12  4:00:00 0.00    6:52  20:26 2013-06-12 04:00:00

当我尝试在 Sunrise 和 Sunset 列上使用 round() 时,我收到一个错误“未使用的参数”。 我不明白为什么。

这是我正在使用的代码行;

round(strptime(mdf$Sunrise, format="%H:%M"), units = "hours")

这是错误:

Error in round.POSIXt(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  : 
  unused argument (units = "hours")

如果我用这个

round(strptime("6:52", format="%H:%M"), units="hours")

我得到这个错误作为回报

Error in round.POSIXt(list(sec = 0, min = 52L, hour = 6L, mday = 12L,  : 
  unused argument (units = "hours")

SessionInfo() 返回

R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

有关如何解决此错误的任何建议?

这行代码是此处提出的另一个问题中建议的一部分; Place 1 heatmap on another with transparency in R

【问题讨论】:

  • round(strptime("6:52", format="%H:%M"), units="hours") 为我工作。请提供reproducible example
  • @JoshuaUlrich 你的例子给我一个错误。编辑了问题以包含此内容。
  • 约书亚的例子对我来说很好。也许你在某个地方重新定义了round?在新的会话中尝试。
  • 那么在你的会话中有些东西掩盖了round.POSIXt。当你加载一个包或者你自己定义了另一个 round.POSIXt 函数时,你可能被警告过。
  • 你也可以通过base::round.POSIXt(strptime("6:52", format="%H:%M"), units="hours")明确要求正确的功能

标签: r


【解决方案1】:

cmets 建议 round.POSIXt 在会话中被屏蔽或重新定义,我们非常有帮助。我开始了一个新的会话,代码现在正在运行。

【讨论】:

  • 感谢您让我们知道,但由于过于本地化而投票结束问题...
猜你喜欢
  • 2018-09-23
  • 1970-01-01
  • 1970-01-01
  • 2016-10-25
  • 1970-01-01
  • 1970-01-01
  • 2015-07-11
  • 1970-01-01
  • 2015-07-18
相关资源
最近更新 更多