library(dplyr) library(lubridate) # Create a sample data frame with datetime series data = read.csv('https://docs.google.com/spreadsheets/d/e/2PACX-1vQP0OK8q9x5XJa9T_DrOr2Hua_MRbW4WrdIRcZszYHtSodmMso5gFp3ieHp9nRjs2zGdnB9lwhpiBXp/pub?gid=388995206&single=true&output=csv') #head(data) data$DateTime = as.POSIXct(paste(data$Date, data$Time), format ="%d/%m/%Y %H:%M:%S") head(data) data = data[,c('DateTime','Name','Amount')] #typeof(data$Date) #data$Date = as.POSIXct(data$Date, format="%d/%m/%Y %H:%M:%S") # #typeof(data$Date) head(data) #df <- data.frame( # DateTime = as.POSIXct(c("2023-01-05 08:00:00", "2023-02-10 10:30:00", "2023-03-15 14:45:00", "2023-04-20 18:20:00")), # Value = c(10, 15, 20, 25) #) #typeof(df$Date) # Define the target month and year #data = subset(data,format(Date, "%m") == "09") #print(data) target_month <- 9 # February target_year <- 2023 # Filter datetime values based on the target month and year filtered_df <- data %>% filter(month(DateTime) == target_month, year(DateTime) == target_year) # Print the filtered data frame print(filtered_df)