Since you are not asking about the time (hourly) part of your data, it is better to store your data as a Date object. Otherwise, you might be interested in chron, which also has some handy features, as you will see below.
As for answering the Conjugate Prior call, you should save the date data as a Date object. Since your data already conforms to the default format ('yyyy-mm-dd'), you can just call as.Date on it. Otherwise, you will need to specify your string format. I would also use your factor as.character to make sure you don't get errors in the string. I know that for this reason I ran into problems with date factors (possibly fixed in the current version).
df.MHwind_load <- transform(df.MHwind_load, Date = as.Date(as.character(Date)))
Now it will be useful for you to create wrapper functions that extract the information you need. You can use the transformation, as I did above, to simply add those columns that represent months, days, years, etc., and then a subset of them logically. Alternatively, you can do something like this:
getMonth <- function(x, mo) {
Or, in short form
getMonth <- function(x, mo) x[month(x) %in% mo]
This is simply a compromise between storing this information (transforming frame) or processing it as desired (use access methods).
A more complex process is your need, say, on the first day of the month. However, this is not entirely difficult. Below is a function that will return all these values, but itβs quite simple to multiply the sorted vector of values ββfor a given month and take them first.
getFirstDay <- function(x, mo) { isMonth <- months(x) %in% mo x <- sort(x[isMonth])
A simpler alternative would be
getFirstDayOnly <- function(x, mo) {sort(x[months(x) %in% mo])[1]}
I did not prototype them, since you did not provide any sample data, but this is the approach that will help you get the information you need. It is up to you to figure out how to include them in your workflow. For example, say that you want to get the first day for each month of a given year (provided that we look only at one year, you can create wrappers or pre-process your vector one year before).
# Return a vector of first days for each month df <- transform(df, date = as.Date(as.character(date))) sapply(unique(months(df$date)),
The above can also be designed as a separate convenience function that uses a different access function. Thus, you create a series of direct but concise methods for obtaining fragments of the necessary information. Then you simply combine them to create very simple and easily interpreted functions that you can use in your scripts to determine exactly what you want.
You can use the examples above to figure out how to prototype other shells to access the date information you need. If you need help with these questions, feel free to ask in the comments.