You can grab my naLast function from my "SOfun" package.
The result would be a matrix, but you can easily wrap it in as.data.frame if you want:
as.data.frame(naLast(mydf, by = "row"))
# X1 X2 X3 X4
# x1 a b c
# x2 d e
# x3 f g h i
# x4 j k l
Install the package with:
library(devtools)
install_github("mrdwab/SOfun")