A user has 3 dataframes and he wants to re-organize by column order.How to do that?

363    Asked by Ajit yadav in Data Science , Asked on Nov 21, 2019
Answered by Ajit yadav

Let us create 3 dataframes with desired values

a <- data.frame("A" = c(1,1), "B" = c(2,2), "C" = c(3,3))

b <- data.frame("A" = c(2,2), "B" = c(3,3), "C" = c(4,4))

c <- data.frame("A" = c(3,3), "B" = c(4,4), "C" = c(5,5))

Now we can use lapply() function to do such thing

lapply(names(x), function(nm) cbind(a[, nm], b[, nm], c[, nm]))



Your Answer

Interviews

Parent Categories