Condense / Aggregate / Summarise


I'm struggling with a functions (apologies if I've created an incorrect tag or subject name - I'm still getting familiar with the functions.

I have a dataset I'm trying to 'condense' (I don't know if that's the right term) but essentially I'm looking to reduce the amount of observations by arranging, thickening (to hours) then summarising the data, but I lose some of the information. I think that either summarise is the wrong function or I'm using incorrectly.

See example of tabled info below:


I'm trying to condense the data by hour, but I want to keep the 'site' column. When I perform the following, I get the summarised information but it cuts off the 'site' reference. Can anyone point out my obvious mistake please?

data_400_hour <- data_400_f5 %>%
arrange(sitetime) %>%
padr::thicken(interval = "hours") %>%
group_by(sitetime_hour) %>%
mutate(SampleNo = row_number()) %>%
summarise(AvActSpd = median("GG SPEED"))

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers.

Screenshots are seldom helpful, and most of us in the community are naturally lazy in the R sense and usually unwilling to try reverse engineering the problem.

So, all I can offer is an outline

With the zoo or lubridate packages convert the date columns to date objects if they are character.

"Round" the date column you are using to half-hour intervals

Using the dplyr package, `group_by(site,date_col) %>% summarize(new_col = VAR, function)

and assign the return to a new object name

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