converting/save data into weekdays


I have hourly data for January and February, and I need to filter the data by day of the week, so that I can separate the data into individual datasets for each day of the week.

Specifically, I need to create separate datasets for Sundays, Mondays, Tuesdays, Wednesdays, Thursdays, Fridays, and Saturdays, each containing the hourly data for that specific day of the week during the months of January and February.

The data can be found in the link below.


You can use the wday function from the lubridate package to label each row with the day of the week. Typically, you would then use the group_by() function from dplyr to do calculations on each group but you can also make subsets based on the DayOfWeek column if you want to.


DF <- read.csv("~/R/Play/sample_data.csv")
DF <- DF |> mutate(DayofWeek = wday(date, label = TRUE))
#>               date AE33_abs_880nm PAX_abs870 House_abs880nm DayofWeek
#> 1 2022-01-16 00:00            NaN        NaN            NaN       Sun
#> 2 2022-01-16 01:00            NaN        NaN            NaN       Sun
#> 3 2022-01-16 02:00            NaN        NaN            NaN       Sun
#> 4 2022-01-16 03:00            NaN        NaN            NaN       Sun
#> 5 2022-01-16 04:00            NaN        NaN            NaN       Sun
#> 6 2022-01-16 05:00            NaN        NaN            NaN       Sun

Created on 2023-01-11 with reprex v2.0.2

1 Like

It worked.
Thank You so much.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.