Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201943

R unbalanced data frame data cleaning

$
0
0

My data frame looks like this:

c1 c2 c3 c4

T1 NA NA NA
NA a  NA NA
NA NA B  NA
NA NA NA b
T2 NA NA NA
NA NA C  NA
NA NA NA c

I want to have it like

c1 c2 c3 c4

T1 a  B b
T2 NA C c

I tried with something like the following, which I saw from another post, but I don't think it applies to my problem, any help please?

stri_list2matrix(lapply(., function(x) x[x!='NA']), fill='', byrow=FALSE)

Viewing all articles
Browse latest Browse all 201943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>