etl_extract.etl_macleish: Extract weather data

Description Usage Arguments Examples

View source: R/etl_extract.R

Description

Retrieve data from the Macleish Field Station weather monitors

Usage

1
2
3
4
5
## S3 method for class 'etl_macleish'
etl_extract(obj, ...)

## S3 method for class 'etl_macleish'
etl_transform(obj, ...)

Arguments

obj

an etl object

...

arguments passed to methods

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
macleish <- etl("macleish")
str(macleish)

## Not run: 
macleish %>%
  etl_extract() %>%
  etl_transform() %>%
  etl_load()
whately <- macleish %>%
  tbl("whately") 
orchard <- macleish %>%
  tbl("orchard") 
  
whately %>%
  summarize(N = n(), avg_temp = mean(temperature))
orchard %>%
  summarize(N = n(), avg_temp = mean(temperature))
  
# check data types
whately %>%
  glimpse()

# if using SQLite, datetimes will get converted to integers
whately <- whately %>%
  mutate(when_datetime = datetime(when, 'unixepoch'))
whately %>%
  glimpse()

# show the most recent data -- should be within the past hour
whately %>%
  collect() %>%
  tail()

# show that no time-shifting is happening
if (require(ggplot2)) {
macleish %>%
  tbl("whately") %>%
  collect() %>%
  mutate(when = lubridate::ymd_hms(when)) %>%
  filter(lubridate::year(when) == 2012 & month(when) == 12 & day(when) == 20) %>%
  ggplot(aes(x = when, y = temperature)) + geom_line()
}

## End(Not run)

macleish documentation built on Sept. 28, 2017, 5:05 p.m.