gpt4 book ai didi

r - R 中的 USNO REST API

转载 作者:行者123 更新时间:2023-12-02 18:06:37 25 4
gpt4 key购买 nike

我正在尝试从US Naval Observatory Rest API中提取月出和设定时间使用 htrr 和 jsonlite 包。但是,我不断收到错误消息,请提供 MM/DD/YYYY 格式的日期。我相信我就是这样,所以很困惑。

library(httr)
library(jsonlite)

GET("https://aa.usno.navy.mil/api/rstt/oneday?date=09/20/2005&coords=47.60,-122.33")

最佳答案

该消息令人困惑,但似乎我们可能需要传入 YYYY-MM-DD 格式

out <- GET("https://aa.usno.navy.mil/api/rstt/oneday?date=2005-09-20&coords=47.60,-122.33")

-输出

out
Response [https://aa.usno.navy.mil/api/rstt/oneday?date=2005-09-20&coords=47.60,-122.33]
Date: 2022-07-24 18:43
Status: 200
Content-Type: application/json
Size: 1.26 kB
{
"apiversion": "3.0.0",
"geometry": {
"coordinates": [
-122.33,
47.6
],
"type": "Point"
},
"properties": {
...

然后,提取内容

library(dplyr)
library(rrapply)
> rrapply(content(out)$properties$data, how = "bind")
closestphase.day closestphase.month closestphase.phase closestphase.time closestphase.year curphase day day_of_week fracillum isdst label
1 18 9 Full Moon 02:01 2005 Waning Gibbous 20 Tuesday 92% FALSE NULL
month moondata.1.phen moondata.1.time moondata.2.phen moondata.2.time moondata.3.phen moondata.3.time sundata.1.phen sundata.1.time
1 9 Rise 02:57 Upper Transit 09:57 Set 17:15 Set 02:13
sundata.2.phen sundata.2.time sundata.3.phen sundata.3.time sundata.4.phen sundata.4.time sundata.5.phen sundata.5.time tz year
1 End Civil Twilight 02:43 Begin Civil Twilight 13:23 Rise 13:54 Upper Transit 20:03 0 2005

通过查看网页,更明显的是指定的格式似乎不正确

enter image description here

关于r - R 中的 USNO REST API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73101013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com