This is the same question as How to identify which columns are not "NA" per row in a matrix? but for a dataframe and not a matrix.
I have a dataframe with 205 rows and 62 columns. I would like to identify the column names for each row that do not have NA as their value. E.g.:
col1 col2 col3 col4 col5 col6
row1 NA NA NA NA fact fact
row2 num num NA NA NA NA
row3 num num NA NA int int
row4 NA NA NA NA fact fact
row5 NA NA int int NA NA
row6 NA NA int NA NA NA
The result should then be:
row1 col5;col6
row2 col1;col2
row3 col1;col2;col5;col6
row4 col5;col6
row5 col3;col4
row6 col3
Ideally the result should be added to the dataframe as an extra column.