This 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)

Arguments

x

A data frame representing the tracking data. It must contain an "ID" column.

y

A data frame representing the new data to be merged. It must contain an "ID" column.

Value

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.

Note

This function assumes that the "ID" column is unique in both data frames.

Examples

# 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)