U_value <- 0.15 # create a vector of room names room_names <- paste0("R", formatC(1:10, width = 2, flag = "0")) # create a data frame with room names as a column room_data <- data.frame(Room = room_names) room_data$Area <- round(runif(10, 1, 3), 3) # view the data frame room_data # create a vector of 24 hours hour <- sprintf("%02d", 0:23) # create a data frame with the Hour column hour_data <- data.frame(Hour = hour) # view the data frame hour_data # set the random seed for reproducibility set.seed(123) # add a new column to the data frame with random values between 10 and 20, rounded to 3 significant digits hour_data$Temperature <- round(runif(24, 10, 20), 1) # view the updated data frame # define the internal temperature # define the internal temperature # define the internal temperature # define the internal temperature # extract the first room area from the room data frame # create a data frame with 24 rows for each hour of the day # create a data frame for 10 rooms with areas # create a data frame for 10 rooms with areas # create a data frame for 10 rooms with areas # create a data frame for 10 rooms with areas # create a data frame for 10 rooms with areas room_data <- data.frame(Room = paste0("R", formatC(1:10, width = 2, flag = "0")), Area = runif(10, 10, 100)) # create a data frame with 24 rows for each hour of the day hour_data <- data.frame(Hour = 1:24) # add a new column to the hour data frame called Temperature, with random values between 10 and 20 hour_data$Temperature <- runif(24, 10, 20) # extract the first room area from the room data frame room_area <- room_data$Area[1] # calculate the product of the room area and temperature for each hour product <- hour_data$Temperature * room_area # add the product as a new column to the hour data frame with the room name as the column name room_name <- row.names(room_data)[1] room_num <- as.integer(substr(room_name, 2)) col_name <- paste0("R", formatC(room_num, width = 2, flag = "0")) hour_data[col_name] <- product # print the resulting hour data frame hour_data