Skip to content

better way to extract flag types#44

Description

@jordansread

From Bryan 馃憤

Code and two examples of the output

Bryan

sensor = window(playTR, type='auto')
#flag(playTR , 'x == 999999', 'persist(x) > 3', 'is.na(x)')
flagged <- flag(sensor,'x < 1','MAD(x,w) > 3')

flaggedout <- data.frame(flagged$sensor) %>%
  add_rownames() %>%
  mutate(flagged = NA_character_) %>%
  mutate(flaggedyes = NA_character_)

for(ii in 1:length(flagged$flags)){

  flageddata <- flagged$flags[[ii]]$flag.i
  flagtype <- flagged$flags[[ii]]$expression

  flaggedout%<>%
    mutate_if(rowname %in% as.character(flageddata), flaggedyes = flagtype) %>%
    mutate(flagged = paste2(flagged,flaggedyes)) %>%
    mutate_if(flagged == "", flagged = NA) %>%
    mutate(flaggedyes = NA_character_)


}

flaggedout %<>% select(-flaggedyes)
#head(data.frame(flaggedout %>% filter(!is.na(flagged))))


idx <- c(1, diff(flaggedout$times))
i2 <- c(1,which(idx > 3600), nrow(flaggedout)+1)
flaggedout$grp <- rep(1:length(diff(i2)), diff(i2))

trplot <- ggplot(flaggedout,  aes(x = times, y = x) )
trplot <- trplot + geom_point(aes(colour = flagged,group = grp))
trplot

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions