There are many NA's in my dataset and I need to shift all those cells (at row level) to the left.
Example- my dataframe:
df=data.frame(x=c("l","m",NA,NA,"p"),y=c(NA,"b","c",NA,NA),z=c("u",NA,"w","x","y"))
df
x y z
1 l <NA> u
2 m b <NA>
3 <NA> c w
4 <NA> <NA> x
5 p <NA> y
I want the above dataframe converted into this:
x y z
1 l u NA
2 m b NA
3 c w NA
4 x <NA> NA
5 p y NA
Please help.
Thanks.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…