Click here for a transcript.
Where we wanted to plot, maybe we just want to focus on September 8th. And so, before we can get into that, we need to create a new column. So, if we create new columns in data frames, we just need to specify it within quotes and square brackets, and in particular, we're going to use the PD to date time, and you can see it's telling me to click it. And what this does is, it takes hours, or it takes dates, and it takes time and combines them into a single date-time object. And so, in order to do that, we need to provide it what our date is. And then we tell it quote space quote, and then we tell it what our time is. And that space just allows the date-time object to not have the time running against the date, but to space it out.
And so, if we look at the top five rows, we can now see that we've got this date time object. Which is a combination of the date and the time, and additionally if we look at the data types of our new data set, we can now see the date time is this special type of data called a date-time object. Which means that we can use it in Boolean or conditional statements to find dates that are greater than our date of Interest or less than.
And so, to go ahead and get that data. We can create a new variable called solar subset in which we want the solar date time that is greater than 2021 September 08. And we want similar data in which the date time is less than the ninth. And so what this will do is, it will extract the data that is above the September 8th at midnight but before September 9th at midnight, so we'll effectively get all 24 hours of September 8th. And then, we don't really need all of the subset. So I'm going to extract a few columns. So, we want we still want all the rules, but we really only want, Well, to show you, we can really just extract date time and produced kilowatt hour. I forgot this print statement here. And so, there is how we could extract just the date time and just the produced kilowatt hour. But it's not necessary because we can always just call out specific values within our gg plot.
So, this is what our new data set looks like, and we can see that now it's just September 8th. So then we can create our line plot. So we can say, gg plot with the subset of data because we're just plotting the eighth at this point, and we can say geom line AES x equals date time as before and Y equals produced kilowatt hour. And so, here we can see that this is looking a lot better. We can see that this is the early hours of September 8th. This is the late hours. We can see that it spiked sometime in the middle of the day, as solar power is likely to do. But we can improve how this looks. I'm just going to copy it, paste it down here, and we can use the theme command as we did with the box plots early on to actually change this axis.
So, we can say axis text X and now before we said element blank because we were removing it, but in this case we're changing it. So, we say element underscore text, and we tell it what we're changing, and so we can just change the angle to 90. And so, now we can see that this is a little bit more readable. And we can see that this spike happens it hasn't attached the time to it, so it's not terribly useful because it's cut off that little bit, but you know we could assume that if the time was here it would be even an even better representation.