I have a data frame like this,
user_name1 user_name2 user_name3
0 Alex 0
0 0 0
0 0 Jacob
0
Lee Mark
John 0 Kevin
I want to rearrange this in this way ignoring 0 or any NA values,
user_name1 user_name2 user_name3
John Alex Jacob
0 Lee Mark
0 0 Kevin
0 0 0
0 0 0
0 0 0
noticeable that, row numbers will be unchanged.
user_name1 <- c(0,0,0,0, "", "John")
user_name2 <- c("Alex", 0,0, "", "Lee",0)
user_name3 <- c(0,0, "Jacob", "", "Mark", "Kevin")
df<- data.frame(user_name1, user_name2, user_name3)