update_ratings.RdThis function updates a tracking data frame with new data. It ensures that the new data has the correct structure, merges it with the existing data, and handles overlapping columns appropriately.
update_ratings(x, y)A data frame with the updated ratings. If the tracking data frame (`x`) only has the "ID" column and no rows, it will be overwritten directly with the new data (`y`). Overlapping columns will be updated, and row names will be removed.
This function assumes that the "ID" column is unique in both data frames.
# Example 1: Updating an empty tracking data frame
tracking_df <- data.frame(ID = character(), stringsAsFactors = FALSE)
new_data <- data.frame(ID = c("A", "B"), Rating = c(5, 3))
updated_df <- update_ratings(tracking_df, new_data)
# Example 2: Updating an existing tracking data frame
tracking_df <- data.frame(ID = c("A", "B"), Rating = c(4, 2))
new_data <- data.frame(ID = c("A", "B"), Rating = c(5, 3))
updated_df <- update_ratings(tracking_df, new_data)