<jupyter_start><jupyter_text>Maximum and minimum temperatures by dayThis is an example of making a (useful?) plot using the functions contained in GetDataFrame.R and the ggplot2 plotting system.<jupyter_code>library(ggplot2)
library(dplyr)
library(reshape)

#+
# This source file contains functions to extract dataframes from the
# hdf5 files
#-
source('GetDataFrame.R')

#+
# Read dataframe from hdf5, use dplyr select() to get just time and temperature
#-
rawds <- getRawDF("../data/monthly-201808.hdf5") %>% select(time,temperature)

#+
# Truncate timestamp to days, summarize by time gettting the 
# minimum and maximum temperatures. Add a difference column
#-
rawds <-  rawds %>% mutate(time=as.POSIXct(trunc(time,"day"))) %>%
          group_by(time) %>% 
          summarise(min=min(temperature), max=max(temperature)) %>%
          mutate(difference=max-min)
#+
# Change the 'time' column name to 'date'
#
colnames(rawds) <- c('date','min','max','difference')

#+
# Melt (stack) the dataframe by date. The casting is necessary because
# melt() does not like dplyr manipulated dataframes
#-
meltds <- melt(as.data.frame(rawds),id='date')

#+
# Display the plot
#-
ggplot(meltds) + geom_line(aes(x=date, y=value, color=variable)) +
        labs(x="Day",y="Temperature ºC", title="Maximum and minimum temperatures by day")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1363301400147384, 'fraction_numerical': 0.008106116433308769, 'mean_word_length': 5.008849557522124, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '217045', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 471, 'n_tokens_neox': 443, 'n_words': 124, 'path': 'analytics/R/PlotMinMaxTemp.ipynb', 'repo_name': 'jguillaumes/MeteoClient', 'size': '1357'}