0

I'm using the rnoaa package for the first time. The data output is in a format I have not used before. How can I convert this to a nice dataframe that is ready to manipulate? below is the code and output

library("rnoaa")
ncdc(datasetid='GHCND', stationid = "GHCND:USC00182906", datatypeid='PRCP', 
startdate = '2006-01-01', enddate = '2007-01-01', limit=400, token =  
"API CODE")

$meta
$meta$totalCount
[1] 169

$meta$pageCount
[1] 400

$meta$offset
[1] 1


$data
    date                    datatype  station         value fl_m fl_q fl_so fl_t
1   2006-07-14T00:00:00     PRCP GHCND:USC00182906     5               H 0700
2   2006-07-15T00:00:00     PRCP GHCND:USC00182906     0               H 0700
3   2006-07-16T00:00:00     PRCP GHCND:USC00182906     0               H 0700
4   2006-07-17T00:00:00     PRCP GHCND:USC00182906     0               H 0700
5   2006-07-18T00:00:00     PRCP GHCND:USC00182906     0               H 0700
6   2006-07-19T00:00:00     PRCP GHCND:USC00182906   109               H 0700
7   2006-07-20T00:00:00     PRCP GHCND:USC00182906     0               H 0700
8   2006-07-21T00:00:00     PRCP GHCND:USC00182906     3               H 0700
4

1 回答 1

1

如果您$data从调用中访问部分结果ncdc(),它已经是一个data.frame. 您无需再做任何事情。您可以将其另存为自己的对象,如下所示。

library("rnoaa")
dataset <- ncdc(datasetid='GHCND', stationid = "GHCND:USC00182906", datatypeid='PRCP', 
          startdate = '2006-01-01', enddate = '2007-01-01', limit=400, token =  
            "API CODE")
df <- dataset$data

要验证它确实是一个data.frame,您可以检查:

> class(df)
[1] "data.frame"
于 2017-04-12T14:12:46.397 回答