library(compareDF)
key <- c('A1', 'B1', 'C1', 'D1', "", "", "","", "25P", "75P", "Average", "Median", "25P", "75P", "Average", "Median")
a<- c(10,20,30,40, 10,20,30,40, 10,20,30,40,10,20,30,40)
b <- c('book', 'pen', 'textbook', 'pencil_case', 'book', 'pen', 'textbook', 'pencil_case', 'book', 'pen', 'textbook', 'pencil_case','book', 'pen', 'textbook', 'pencil_case')
c <- c(TRUE,FALSE,TRUE,FALSE, TRUE,FALSE,TRUE,FALSE, TRUE,FALSE,TRUE,FALSE, TRUE,FALSE,TRUE,FALSE)
d <- c(2,5, 8, 10, 7, 2,5, 8, 10, 7, 2,5, 8, 10, 7,1)
df_1_New <- data.frame(key,a,b,c,d)
key <- c('A1', 'B1', 'C1', 'D1', "", "", "","", "25P", "75P", "Average", "Median", "25P", "75P", "Average", "Median")
a <- c(10,5,40,40, 10,5,40,40,10,5,40,40, 10,5,40,40)
b <- c('book', 'pen', 'textbook', 'pen_case', 'book', 'pen', 'textbook', 'pen_case', 'book', 'pen', 'textbook', 'pen_case','book', 'pen', 'textbook', 'pen_case')
c <- c(TRUE,FALSE,TRUE,TRUE, TRUE,FALSE,TRUE,TRUE, TRUE,FALSE,TRUE,TRUE, TRUE,FALSE,TRUE,TRUE)
d <- c(2,5, 3, 10,2,5, 3, 10, 2,5, 3, 10, 2,5, 3, 10)
df_1_Old <- data.frame(key, a, b, c, d)
ctable <- compare_df(df_1_New, df_1_Old, c("key"), keep_unchanged_cols = FALSE)
DF_1_Diff <- ctable$comparison_df
if you try the above code you will find that in key column "average , percentile coming twice and there also some blank cell. I want to remove all and keep only the A1, B1, C1 and D1. you will also notice the chng column which showing '+' and '-' row. want to keep only the '+' value and drop the chng column.
Answer I am expecting . which column and row in which change has been made:-
key a b c d
B1 20 pen FALSE 5
C1 30 textbook TRUE 8
D1 40 pencil_case FALSE 10
but I am getting
!key chng_type a b c d
+ 10 book TRUE 7
+ 20 pen FALSE 2
+ 30 textbook TRUE 5
+ 40 pencil_case FALSE 8
- 10 book TRUE 2
- 5 pen FALSE 5
- 40 textbook TRUE 3
- 40 pen_case TRUE 10
25P + 10 book TRUE 10
25P + 10 book TRUE 8
25P - 10 book TRUE 2
75P + 20 pen FALSE 7
75P + 20 pen FALSE 10
75P - 5 pen FALSE 5
Average + 30 textbook TRUE 2
Average + 30 textbook TRUE 7
Average - 40 textbook TRUE 3
B1 + 20 pen FALSE 5
B1 - 5 pen FALSE 5
C1 + 30 textbook TRUE 8
C1 - 40 textbook TRUE 3
D1 + 40 pencil_case FALSE 10
D1 - 40 pen_case TRUE 10
Median + 40 pencil_case FALSE 5
Median + 40 pencil_case FALSE 1
Median - 40 pen_case TRUE 10