What is the difference between dcast and recast in R?
See ?reshape2::recast: The function 


  conveniently wraps melting and (d)casting a data frame into a single
  step.


library(reshape2)
recast(df_sample, Countries+variable~Type, id.var=1:2)
#   Countries variable  a    b
# 1 Australia    X2014 30  -40
# 2 Australia    X2015 50  -10
# 3 Australia    X2016 10 -100
# 4 Australia    X2017  5  -10
# 5       USA    X2014 10  -20
# 6       USA    X2015 20  -40
# 7       USA    X2016 15  -10
# 8       USA    X2017  5   -5


So, it's just a shortcut for these two steps:

(tmp &lt;- melt(df_sample, id.vars=1:2))
#    Countries Type variable value
# 1        USA    a    X2014    10
# 2        USA    b    X2014   -20
# 3  Australia    a    X2014    30
# 4  Australia    b    X2014   -40
# 5        USA    a    X2015    20
# ...
dcast(tmp, Countries+variable~Type)
#   Countries variable  a    b
# 1 Australia    X2014 30  -40
# 2 Australia    X2015 50  -10
# 3 Australia    X2016 10 -100
# 4 Australia    X2017  5  -10
# 5       USA    X2014 10  -20
# 6       USA    X2015 20  -40
# 7       USA    X2016 15  -10
# 8       USA    X2017  5   -5