Dear R users, How to find all single minima within each next part of analyzed vector (table) Select all minima (mass_value=min & mass_value<2) (many) in vector(table), BUT first put mask on table in order to select within one window mask (5 elements) only one local minimum, and next to search within the next time window mask the second minimum (only one local along second mask) mass_position<-c(1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20) mass_value<-c(9,2,3,2,5,6,7,8,9,10,2.1,12, 1,14,15,16,17,18,19,20) mass_label<-c("lab1","lab2","lab3","lab4","lab5","lab6","lab7","lab8","lab9","lab10", "lab11","lab12","lab13","lab14","lab15","lab16","lab17","lab18","lab19","lab20")
dt<-5 # i.e. mass_value<-c (9,0,3,1,5,6,7,8,3,10,2.1,12, 1, 1,15,16,17,18,19,20) mass_position<-c(1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20) # - - - - - # 1 x first needed min= 0, pos=2 #(only one within first mask) # - - - x - # (min= 3, but & ( 3 is not <2)) =>there is not min for us locally # - - - - - # 1 x 2nd needed min=1,pos=13 # not min=1 on position 14, because we want only 1 min locally # and only one locally within each NEXT 5 elements) # # . . . . . #correct answer would be vector : # "lab2","lab13" #expected answer = local_min_positions = (2 ,13 ) local_min_values = (0 ,1 ) local_min_labels = ("lab2","lab13") How to find labels from my_label: for all localizations of different minima in mass, but within time window there can be only one minimum, i.e. in dt=5 second wide time window there can be only one minimum Yours sincerely, Eugen [[alternative HTML version deleted]] ______________________________________________ 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.