Count Non-NA Values in R (2 Examples) | Vector & Data Frame Columns / Rows | sum & is.na Functions

Published: 24 January 2023
on channel: Statistics Globe
1,033
14

How to get the number of non-NA values in the R programming language. More details: https://statisticsglobe.com/count-non...
R code of this video:

vec <- c(1, NA, 2, NA, NA, 1, 2, 1, NA) # Create example vector
vec # Print example vector

sum(!is.na(vec)) # Get number of non-NA values

data <- data.frame(x1 = c(5, NA, 7, NA, NA, 3), # Create example data frame
x2 = c("a", "b", NA, NA, "a", "c"))

colSums(!is.na(data)) # Get number of non-NA values in columns

rowSums(!is.na(data)) # Get number of non-NA values in rows

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – R Programming Group for Discussions & Questions:   / statisticsglobe  
Facebook – Python Programming Group for Discussions & Questions:   / statisticsglobepython  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – R Programming Group for Discussions & Questions:   / 12555223  
LinkedIn – Python Programming Group for Discussions & Questions:   / 12673534  
Twitter:   / joachimschork  

Music by bensound.com


On this page of the site you can watch the video online Count Non-NA Values in R (2 Examples) | Vector & Data Frame Columns / Rows | sum & is.na Functions with a duration of hours minute second in good quality, which was uploaded by the user Statistics Globe 24 January 2023, share the link with friends and acquaintances, this video has already been watched 1,033 times on youtube and it was liked by 14 viewers. Enjoy your viewing!