Skip to content

Instantly share code, notes, and snippets.

@tetlabo
Last active April 17, 2021 17:12
Show Gist options
  • Save tetlabo/a9062afece6c3ae1a5a5c8d5ca7ab2c7 to your computer and use it in GitHub Desktop.
Save tetlabo/a9062afece6c3ae1a5a5c8d5ca7ab2c7 to your computer and use it in GitHub Desktop.
ambientweatheRパッケージの使用例02
library(ambientweatheR)
library(tidyverse)
library(weathermetrics) # APIが華氏で温度を返してくるため、変換に使う
mac_address <- list_user_devices() %>% flatten() %>% pluck("macAddress")
df <- seq.Date(as.Date("2021-04-09"), as.Date("2021-04-17"), "day") %>%
map(as.character) %>%
map_df(~ fetch_device_data(mac_address, .x)$content) %>%
mutate(tempc = fahrenheit.to.celsius(tempf),
tempinc = fahrenheit.to.celsius(tempinf),
feelsLikec = fahrenheit.to.celsius(feelsLike),
feelsLikeinc = fahrenheit.to.celsius(feelsLikein),
dewPointc = fahrenheit.to.celsius(dewPoint),
dewPointinc = fahrenheit.to.celsius(dewPointin))
df %>%
select(date_time, tempc, feelsLike, dewPoint) %>%
gather(key = "key", value = "value", -date_time) %>%
ggplot(aes(x = date_time, y = value, colour = key)) +
geom_point()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment