Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better way to extract flag types #44

Open
jordansread opened this issue Jun 24, 2016 · 0 comments
Open

better way to extract flag types #44

jordansread opened this issue Jun 24, 2016 · 0 comments

Comments

@jordansread
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant