I have a data structure like the one below.
df <- structure(list(id = c(1, 1, 1, 2, 2, 3, 3, 4, 4), HT = c("L",
"L", "L", "W", "W", "B", "B", "WA", "WA"), HS = c(4, 4, 4, 0,
0, 3, 3, 0, 0), AT = c("N", "N", "N", "M", "M", "S", "S", "BR",
"BR"), AS = c(1, 1, 1, 5, 5, 1, 1, 3, 3), T = c("L", "L", "N",
"W", "M", "B", "S", "WA", "BR"), H_A = c("H", "H", "A", "H",
"A", "H", "A", "H", "A"), S_incorrect_value = c(3, 3, 1, 0, 5,
3, 0, 0, 2), S_corrected_value = c(4, 4, 1, 0, 5, 3, 1, 0, 3)), row.names = c(NA,
-9L), class = c("tbl_df", "tbl", "data.frame"))
However, it contains some inconsistent values that need to be replaced with a new column to be created (S_corrected_value).
The column with the desired values will be in long format, and correspond to values from two other columns. There are also different numbers of rows that make up each case (id). I have left marked in color to be noticed where the data is scraped from.
