Last active
April 17, 2021 17:12
-
-
Save tetlabo/a9062afece6c3ae1a5a5c8d5ca7ab2c7 to your computer and use it in GitHub Desktop.
ambientweatheRパッケージの使用例02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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