Skip to content
Prev 69287 / 398530 Next

2 simple questions

sms13+ at pitt.edu wrote:

            
Use vector indexing on patlist such as
   patlist[1:10]
which return a list of the first 10 elements.
Please read the docs on object indexing.
No, lapply is NOT a loop, instead think vectorized:

   ## at first look at a logical vector, where the condition holds:
   temp <- sapply(mylist, function(x)
       (is.na(x$date1[1]) & !is.na(x$date2[1])))
   ctr <- sum(temp) # and sum that vector

Uwe Ligges