I'm a beginner R user (not entirely sure if it's the most appropriate language for this use) and am having difficulty coming up with a solution for what I think is probably relatively easy.
EDIT - The first 60 frames of my data look as follows:
structure(list(Filename = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L), .Label = c("BJB1NRL.mat", "DJG1NRL.mat",
"DMA1NRL.mat", "DWS1NRL.mat", "EJC1NRL.mat", "FMB1NRL.mat", "GPC1NRL.mat",
"GZZ1NRL.mat", "JMC1NRL.mat", "JTH1NRL.mat", "KAN1NRL.mat", "MAS1NRL.mat",
"MFM1NRL.mat", "MJU1NRL.mat", "OVK1NRL.mat", "PCA1NRL.mat", "RHG1NRL.mat",
"RHM1NRL.mat", "RJS1NRL.mat", "SIS1NRL.mat", "SXV1NRL.mat", "TXN1NRL.mat"
), class = "factor"), Label = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "V", class = "factor"),
seg_Start = c(231.537, 231.537, 231.537, 231.537, 231.537,
231.537, 231.537, 231.537, 231.537, 231.537, 231.537, 231.537,
231.537, 231.537, 231.537, 231.537, 231.537, 231.537, 231.537,
231.537, 231.537, 231.537, 554.141, 554.141, 554.141, 554.141,
554.141, 554.141, 554.141, 554.141, 554.141, 554.141, 554.141,
554.141, 554.141, 554.141, 554.141, 554.141, 554.141, 554.141,
554.141, 554.141, 554.141, 554.141, 554.141, 554.141, 554.141,
554.141, 554.141, 554.141, 554.141, 554.141, 554.141, 554.141,
554.141, 554.141, 554.141, 1081.457, 1081.457, 1081.457),
seg_End = c(444.039, 444.039, 444.039, 444.039, 444.039,
444.039, 444.039, 444.039, 444.039, 444.039, 444.039, 444.039,
444.039, 444.039, 444.039, 444.039, 444.039, 444.039, 444.039,
444.039, 444.039, 444.039, 887.246, 887.246, 887.246, 887.246,
887.246, 887.246, 887.246, 887.246, 887.246, 887.246, 887.246,
887.246, 887.246, 887.246, 887.246, 887.246, 887.246, 887.246,
887.246, 887.246, 887.246, 887.246, 887.246, 887.246, 887.246,
887.246, 887.246, 887.246, 887.246, 887.246, 887.246, 887.246,
887.246, 887.246, 887.246, 1269.05, 1269.05, 1269.05), t_ms = c(230L,
240L, 250L, 260L, 270L, 280L, 290L, 300L, 310L, 320L, 330L,
340L, 350L, 360L, 370L, 380L, 390L, 400L, 410L, 420L, 430L,
440L, 550L, 560L, 570L, 580L, 590L, 600L, 610L, 620L, 630L,
640L, 650L, 660L, 670L, 680L, 690L, 700L, 710L, 720L, 730L,
740L, 750L, 760L, 770L, 780L, 790L, 800L, 810L, 820L, 830L,
840L, 850L, 860L, 870L, 880L, 890L, 1080L, 1090L, 1100L),
CPP = c(0, 0, 19.553, 16.063, 18.09, 21.547, 21.37, 21.616,
18.125, 20.936, 20.134, 23.642, 23.319, 24.674, 22.299, 22.587,
27.477, 25.924, 20.166, 20.195, 16.807, 18.189, 16.843, 16.07,
20.384, 26.11, 26.536, 28.891, 26.769, 27.622, 28.303, 24.373,
22.043, 23.579, 26.797, 26.384, 29.34, 31.437, 31.531, 24.404,
22.396, 26.416, 28.531, 26.735, 28.796, 28.494, 27.177, 27.325,
26.273, 29.066, 24.344, 21.124, 28.363, 24.193, 19.815, 11.897,
14.125, 0, 0, 22.398)), .Names = c("Filename", "Label", "seg_Start",
"seg_End", "t_ms", "CPP"), row.names = c(NA, 60L), class = "data.frame")
What I have to do is straightfoward to do manually, but I'm struggling to create a script to do it for me. For each time segment (i.e. 231-444, then 1081-1269 etc) I need to see how many milliseconds it takes for the value in the final column (CPP) to reach a threshold value (e.g. 28). That is, I need to count how many rows from the segment starting (t_ms = seg_Start) until the value in the final row reaches this threshold value, since each row is 10ms. If the value never reaches the threshold then a value of 0 should be given.
So far, my code is mostly my attempts to split the dataset up accordingly to be analysed. It is likely inefficient, and more worringly, incorrect.
EDIT - for clarification - I need to analyse the 'CPP' values for each "segment" separately, for each different 'Filename'. One segment is the values in 't_ms' between 'seg_Start' and 'seg_End'.
For example, for the first segment for the first filename, my answer would be '280ms' - each row is 10ms. The first time CPP reaches 28 in the time segment between the first seg_start - seg_End is in row 28 (value = 28.891). 10 x 28 = 280ms.
FINAL EDIT Removed extraneous datasets. Left parts relevant to question only.
Aucun commentaire:
Enregistrer un commentaire