For a column in R dataframe, even if one value is not NA, then replace all NA's with that value?

by Saahil   Last Updated September 12, 2018 00:26 AM

I have a dataframe in R with more than 20 columns and a few million rows. For a given id, the dataframe can have about 100 observations. The way I have created this dataframe is by merging two data frames. So for a given id, for a column say date, even if one of the values is not NA, then I want to replace all NA values in the date column for that id with the value I found. This column is generated by me in some other code so it can have either a single unique value or NA and nothing else.

The closest similar question I could find was this

Tags : r dataframe


Related Questions





Pyspark - Get X random records from dataframe

Updated March 31, 2017 15:26 PM