Dear R users, I was wondering if someone could suggest a few lines of code for my problem.
I want to count the number and the length of strings of NA in a vector. For example: vec <- c(1, 2, 1, NA, NA, 1, 2, NA, NA, NA, 3, 4, NA, NA) has 2 strings of NA's of length 2 and 1 string of NA' of length 3. I can easily count the number of NA's per vector, but I am having a hard time counting the number and length of strings of NA's per vector without relying heavily on loops. I will have to perform this task for many vectors. Can somebody help? many thanks, Marie-Pierre ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.