Find the number of columns between the first and last non NA value

I have the following dataframe,


I would like to add a column that indicates the number of columns from the first until the last non NA value. That is for the first row the value in this additional column would be 2, for the second row it would be 7, and for the last it would be 5.

Read more here:

Content Attribution

This content was originally published by vasile at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: