# Load necessary libraries library(dplyr) library(lubridate) # Set start date and time start_datetime <- mdy_hm("01/01/2024 00:00") # Generate DateTime values with 30-minute intervals for one week datetime_values <- seq(start_datetime, by = "30 min", length.out = 2 * 24 * 7) # Create a data frame with DateTime column df <- data.frame(DateTime = datetime_values) # Add a new column "Temperature" following a sine pattern period_hours <- 24 midday_peak_temp <- 300 midnight_low_temp <- 50 df$Temperature <- midday_peak_temp - ((midday_peak_temp - midnight_low_temp) / 2) * (1 + sin(2 * pi * hour(df$DateTime) / period_hours)) # Format DateTime column to MM/DD/YYYY HH:mm df$DateTime <- format(df$DateTime, "%m/%d/%Y %H:%M") # Write the dataset to a CSV file write.csv(df, file = "dataWEEK2.csv", row.names = FALSE, quote=FALSE,col.names = FALSE) # Print a message indicating successful creation of the CSV file cat("CSV file 'dataWEEK2.csv' has been created.\n")