Sadukie’s SensoRs AdventuRes

The Project

My husband has various temperature and humidity sensors scattered throughout the house, recording data points to a MySQL server. The data is stored on a table that looks like this:

id
<int>
date
<chr>
sensorname
<chr>
sensorvalue
<dbl>
1 31 2016-12-18 22:20:23 temp5 63.6116
2 32 2016-12-18 22:20:23 finalDHTTempF2 68.0000
3 33 2016-12-18 22:20:23 humidity2 36.0000
4 34 2016-12-18 22:25:23 temp5 64.1750
5 35 2016-12-18 22:25:23 finalDHTTempF2 68.0000
6 36 2016-12-18 22:25:23 humidity2 36.0000
7 37 2016-12-18 22:30:23 temp5 63.7250
8 38 2016-12-18 22:30:23 finalDHTTempF2 69.8000
9 39 2016-12-18 22:30:23 humidity2 35.0000
10 40 2016-12-18 22:35:23 temp5 63.3866

I wanted to use his dataset to test my adventures in applying R.

Our current dataset data is a data frame with 198164 rows.

The Problem

Looking at this data, the first thing I thought was untidy. There has to be a better way. When I think of tidy data, I think of the tidyr package, which is used to help make data tidy, easier to work with. Specifically, I thought of the spread() function, where I could break things up. Once data was spread into appropriate columns, I figure I can operate on the data a bit better.

The Adventures so far…

As seen in the date field, the values are logged with their times. This is why we have so many data points. The first thing I wanted to do was group the values into daily means.

Cleaning up Dates

I am using lubridate to make some of my date management a bit easier. I am using dplyr to do the chaining with %>%. I grouped my data by sensor then by date parts – year, month, and day. After grouping the data, I summarized the data to get daily means. Once the data was summarized, I spread it out to make it more meaningful:

year(date)
<dbl>
month(date)
<dbl>
day(date)
<int>
finalDHTTempF1
<dbl>
finalDHTTempF2
<dbl>
finalDHTTempF3
<dbl>
humidity1
<dbl>
1 2016 12 18 NA 68.34286 NA NA
2 2016 12 19 NA 67.77578 NA NA
3 2016 12 20 NA 67.88750 NA NA
4 2016 12 21 NA 68.95625 NA NA
5 2016 12 22 NA 69.74375 NA NA
6 2016 12 23 NA 69.71875 NA NA
7 2016 12 24 NA 70.97500 NA NA
8 2016 12 25 NA 70.85625 NA NA
9 2016 12 26 NA 71.78750 NA NA
10 2016 12 27 NA 71.08750 NA NA
finalDHTTempF1
<dbl>
finalDHTTempF2
<dbl>
finalDHTTempF3
<dbl>
humidity1
<dbl>
humidity2
<dbl>
humidity3
<dbl>
temp4
<dbl>
temp5
<dbl>
NA 68.34286 NA NA 35.80952 NA NA 63.08703
NA 67.77578 NA NA 35.55709 NA NA 62.37841
NA 67.88750 NA NA 35.50347 NA NA 62.41281
NA 68.95625 NA NA 35.46528 NA NA 63.40109
NA 69.74375 NA NA 35.24306 NA NA 64.36713
NA 69.71875 NA NA 35.25000 NA NA 64.33000

Cleaning up NAs

Now some of the data shows NA. If there’s anything I’ve learned with data, NULL and NA can be problematic, depending on the data tool and the user operating said tool. In this case, I can easily convert my NA values to 0 without ruining the data meaning:

finalDHTTempF1
<dbl>
finalDHTTempF2
<dbl>
finalDHTTempF3
<dbl>
humidity1
<dbl>
humidity2
<dbl>
humidity3
<dbl>
temp4
<dbl>
temp5
<dbl>
0 68.34286 0 0 35.80952 0 0 63.08703
0 67.77578 0 0 35.55709 0 0 62.37841
0 67.88750 0 0 35.50347 0 0 62.41281
0 68.95625 0 0 35.46528 0 0 63.40109
0 69.74375 0 0 35.24306 0 0 64.36713
0 69.71875 0 0 35.25000 0 0 64.33000

Presentation

So now that I have daily averages in a format that I can work with, let’s do something meaningful with the data – let’s plot it! I am using ggplot2 for plotting.

Conclusion

So far, I’m having fun putting my skills to work, especially with this dataset at. I’m at the tail end of the 2nd course of an R specialization on Coursera. Between CodeMash and Coursera, I’ve been enjoying my exploRation into R. Here’s to many adventures ahead!

The Geekette’s Wardrobe – Featuring Svaha

Disclaimer: I am not affiliated in any way with Svaha Apparel.  It all started with a Facebook ad, and then I noticed them – geeky dresses WITH POCKETS.  So what’s a geekette to do when she finds fun dresses WITH POCKETS and fun geeky pieces?  She blogs about it!


Last weekend, I was busy playing superhero, having fun with some of the behind-the-scenes logistics and social media for Cleveland Space Apps.  Since I had a little more visibility, I figured I’d be fine wearing my geeky outfits – after all, if a geekette can’t be wearing her geeky outfits at a NASA, we have other problems.

Photo courtesy of NASA Glenn Library

Friday night, I was wearing the Gear Train Stripes Sheath Dress.  I have always been intrigued by gears, and I love using them to signify movement, as indicated in my logo for Cleveland Tech Events / Cleveland Tech Consulting.  So when I saw this dress, I knew I had to have it.  Add to it that it has pockets – as a mom and someone on the go, if I can get away with pockets and not a purse or one more bag to carry, I’m going to take advantage of the opportunity.  This dress was so comfortable to wear and work in.  Whether I was moving to unload my van full of supplies for the weekend from one mega Supermarket Sweep like trip at Sam’s Club or speaking at the podium on weekend logistics, this dress worked well for me!

Thank you for flying Air Circuitry!

Saturday was a busy day – fellow space geeks were hacking on NASA’s Space Apps Challenges.  I was working through logistics and social media fun throughout the weekend.  Toward the end of the day, I was going to put snacks out, but then I remembered a few events and instances at prior places of employment where I remember them bringing snacks to us while we worked.  I appreciated that they’d feed us while we worked, with minimal interruption.  So I brought the concept of the snack cart to Cleveland Space Apps.  So here I am, getting ready to set off on an adventure with our snack cart in my Circuit Board Fit & Flare Dress.  I couldn’t resist making the Air Circuitry comment – so much fun!

But it isn’t just about dresses!  I love that Svaha Apparel has so many geeky options.  On Sunday, I was rocking a Pi Spiral Polka Dots Top:

I love how comfortable the material is and how colorful the designs are.  Being a typical geek, a lot of my wardrobe involves black, dark grey, and dark blue shirts.  However, there are moments where I love to add a bit more color and energy to my wardrobe.

And Svaha Apparel isn’t just for adults!  They have A LOT of designs for children, including geeky dresses for the children!   I imagine if I had a little girl that I’d be buying more of those dresses.  However, I am a mom to boys – so instead of dresses, I’m buying a lot of geeky T-shirts. (It also helps that my husband is as much of a geek as I am.)

My husband brought the boys to visit me at NASA on Sunday, and they too were in Svaha Apparel.  My younger one was wearing the Retro Solar System Glow-in-the-Dark Kids T-Shirt, and my older one was wearing the Future Astronaut Kids T-Shirt:

If you’re looking for geeky gear that’s comfortable to wear, I highly recommend checking out Svaha Apparel!

And if you’re Svaha Apparel and you’re reading this, I’d LOVE to see a lot of those kids shirts in adult sizes – so many fun designs, why do the kids get to have all the fun? 🙂