Dear Abby, Thank you. I will look at your stimulated data and then run the code with it. But since I am dealing with real data and also have volumes of it, I would like to send my real data to you. The OULU05 is attached with dput function. It is labeled Ogbos_dput. I would be surprised if it was stripped off. Then I will resend it. If, on the other hand, you don't want it as dput data, then I will email the large data through your private box. Warmest regards Ogbos On Sun, Feb 16, 2020, 08:14 Abby Spurdle <spurdle.a at gmail.com> wrote:> Note that your post does not contain a minimal reproducible example. > I, and presumably most other readers, do not have the file "OULU05". > > Also, your first post referred to "% CR variation", however, your > second post referred to "counts". > > I created a simple simulated data set: > > -------- > sim.data = function () > { year = 1:100 > month = (0:99 %% 12) + 1 > day = (0:99 %% 28) + 1 > counts = sample (1:2000, 100) > data.frame (year, month, day, counts) > } > data = sim.data () > -------- > > After replacing the "data" object (as above), everything worked fine. > (Except that the inequality needed modification based on the value of > counts). > > Maybe the problem is with your dataset...? > Or maybe there's some step in your code that results in missing > values, given your input? > > Also note that the head and tail functions, are useful for both > inspecting data, and describing your data to others. > > -------- > head (data) > tail (data) > -------- >[[alternative HTML version deleted]]
Dear Abby, I have run your code with the generated data. Thanks. The first script still runs OK while the second script had the same issues with your generated data (it could not identify the pits). I will try to attach the data, OULU05. The head and tail of the data are: year month day counts 1 5 1 1 6080 2 5 1 2 6027 3 5 1 3 5824 4 5 1 4 5807 5 5 1 5 5828 6 5 1 6 5888 and year month day counts 360 5 12 26 6281 361 5 12 27 6288 362 5 12 28 6274 363 5 12 29 6272 364 5 12 30 6258 365 5 12 31 6150 Best regards Ogbos On Sun, Feb 16, 2020 at 8:57 AM Ogbos Okike <giftedlife2014 at gmail.com> wrote:> > Dear Abby, > Thank you. I will look at your stimulated data and then run the code with it. > > But since I am dealing with real data and also have volumes of it, I would like to send my real data to you. > > The OULU05 is attached with dput function. It is labeled Ogbos_dput. I would be surprised if it was stripped off. Then I will resend it. If, on the other hand, you don't want it as dput data, then I will email the large data through your private box. > Warmest regards > Ogbos > > On Sun, Feb 16, 2020, 08:14 Abby Spurdle <spurdle.a at gmail.com> wrote: >> >> Note that your post does not contain a minimal reproducible example. >> I, and presumably most other readers, do not have the file "OULU05". >> >> Also, your first post referred to "% CR variation", however, your >> second post referred to "counts". >> >> I created a simple simulated data set: >> >> -------- >> sim.data = function () >> { year = 1:100 >> month = (0:99 %% 12) + 1 >> day = (0:99 %% 28) + 1 >> counts = sample (1:2000, 100) >> data.frame (year, month, day, counts) >> } >> data = sim.data () >> -------- >> >> After replacing the "data" object (as above), everything worked fine. >> (Except that the inequality needed modification based on the value of counts). >> >> Maybe the problem is with your dataset...? >> Or maybe there's some step in your code that results in missing >> values, given your input? >> >> Also note that the head and tail functions, are useful for both >> inspecting data, and describing your data to others. >> >> -------- >> head (data) >> tail (data) >> --------
The data are different sizes. (As I suggested in my first post). The turnpoints function removes "ex-aequos". Replace the following: ------ minima<-which(tp$pit & data$residual<= 20) ----- With: ------ pits = rep (FALSE, nrow (data) ) pits [tp$pos] = tp$pits minima<-which(pits & data$residual<= -100) ------ Should remove the warning. But there's a second problem: range (data$residual) output: [1] -14.97602 11.53771 There are no "residuals less than -100. So you'll need to fix that too. B. On Sun, Feb 16, 2020 at 10:32 PM Ogbos Okike <giftedlife2014 at gmail.com> wrote:> > Dear Abby, > Thank you. I will look at your stimulated data and then run the code with it. > > But since I am dealing with real data and also have volumes of it, I would like to send my real data to you. > > The OULU05 is attached with dput function. It is labeled Ogbos_dput. I would be surprised if it was stripped off. Then I will resend it. If, on the other hand, you don't want it as dput data, then I will email the large data through your private box. > Warmest regards > Ogbos > > On Sun, Feb 16, 2020, 08:14 Abby Spurdle <spurdle.a at gmail.com> wrote: >> >> Note that your post does not contain a minimal reproducible example. >> I, and presumably most other readers, do not have the file "OULU05". >> >> Also, your first post referred to "% CR variation", however, your >> second post referred to "counts". >> >> I created a simple simulated data set: >> >> -------- >> sim.data = function () >> { year = 1:100 >> month = (0:99 %% 12) + 1 >> day = (0:99 %% 28) + 1 >> counts = sample (1:2000, 100) >> data.frame (year, month, day, counts) >> } >> data = sim.data () >> -------- >> >> After replacing the "data" object (as above), everything worked fine. >> (Except that the inequality needed modification based on the value of counts). >> >> Maybe the problem is with your dataset...? >> Or maybe there's some step in your code that results in missing >> values, given your input? >> >> Also note that the head and tail functions, are useful for both >> inspecting data, and describing your data to others. >> >> -------- >> head (data) >> tail (data) >> --------
Ogbos Okike
2020-Feb-16 22:15 UTC
[R] Identification of Turning Points in a Signal: Problem Fixed
Dear Abby, I am very happy to report that the three lines you added have completely solved the problem. It is great to me. I have, for the past one week, approached the problem from various angles without much success. Thank you. Warmest regards Ogbos On Sun, Feb 16, 2020 at 9:30 PM Abby Spurdle <spurdle.a at gmail.com> wrote:> > The data are different sizes. > (As I suggested in my first post). > > The turnpoints function removes "ex-aequos". > > Replace the following: > ------ > minima<-which(tp$pit & data$residual<= 20) > ----- > > With: > ------ > pits = rep (FALSE, nrow (data) ) > pits [tp$pos] = tp$pits > minima<-which(pits & data$residual<= -100) > ------ > > Should remove the warning. > > But there's a second problem: > > range (data$residual) > output: > [1] -14.97602 11.53771 > > There are no "residuals less than -100. > So you'll need to fix that too. > > > B. > > > On Sun, Feb 16, 2020 at 10:32 PM Ogbos Okike <giftedlife2014 at gmail.com> wrote: > > > > Dear Abby, > > Thank you. I will look at your stimulated data and then run the code with it. > > > > But since I am dealing with real data and also have volumes of it, I would like to send my real data to you. > > > > The OULU05 is attached with dput function. It is labeled Ogbos_dput. I would be surprised if it was stripped off. Then I will resend it. If, on the other hand, you don't want it as dput data, then I will email the large data through your private box. > > Warmest regards > > Ogbos > > > > On Sun, Feb 16, 2020, 08:14 Abby Spurdle <spurdle.a at gmail.com> wrote: > >> > >> Note that your post does not contain a minimal reproducible example. > >> I, and presumably most other readers, do not have the file "OULU05". > >> > >> Also, your first post referred to "% CR variation", however, your > >> second post referred to "counts". > >> > >> I created a simple simulated data set: > >> > >> -------- > >> sim.data = function () > >> { year = 1:100 > >> month = (0:99 %% 12) + 1 > >> day = (0:99 %% 28) + 1 > >> counts = sample (1:2000, 100) > >> data.frame (year, month, day, counts) > >> } > >> data = sim.data () > >> -------- > >> > >> After replacing the "data" object (as above), everything worked fine. > >> (Except that the inequality needed modification based on the value of counts). > >> > >> Maybe the problem is with your dataset...? > >> Or maybe there's some step in your code that results in missing > >> values, given your input? > >> > >> Also note that the head and tail functions, are useful for both > >> inspecting data, and describing your data to others. > >> > >> -------- > >> head (data) > >> tail (data) > >> --------