I am having a data set that is having banking details in Excel:
A B C
Name XYZ trash
Date 20/05/31 trash
Amount trash 0.01
Name ABC trash
Date 20/06/30 trash
Amount trash 0.02
Name KLM trash
Date 20/07/29 trash
Amount trash -0.03
The result I want is:
Name Date Amount
XYZ 20/05/31 0.01
ABC 20/06/30 0.02
KLM 20/07/29 -0.03
To clean that df, I have implemented the below code:
sel_col <- c("Name" = 2, "Date" = 2, "Amount" = 3)
df <- df %>%
mutate(D = sel_col[match(df$A, names(sel_col))]) %>%
mutate(E = recode(D, A, B, C)) %>%
select(A, E)
How to split and transpose that? And is it the best way to go?