I'm trying to sum the number of NULL values in my dataframe in R. I can easily do so with NA values using the code below:
colSums(is.na(df))
but when I attempt to do this with is.null I get back the following error:
Error in colSums(is.null(df)) : 'x' must be an array of at least two dimensions
I believe the solution is to change the dataframe into another form to do this - but I don't know how and internet searches have proven fruitless (and often conflate NAs and NULLs)
is.na()returns a logical matrix with the same dimensions as the data frame, whereasis.null()returns a single TRUE/FALSE value. It would help to see some or all of the datadf(including the NULL values) using e.g.dput(df)ordput(head(df)). NULL may not mean what you think it means e.g. it may be stored as type character.