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

Data downsampling #90

Open
kaijagahm opened this issue Apr 7, 2023 · 2 comments
Open

Data downsampling #90

kaijagahm opened this issue Apr 7, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@kaijagahm
Copy link
Owner

Atlastools theoretically does this, but it requires a weird data format and the function is really buggy. (Function atl_thin_data).

For now, implement a quick-and-dirty method inside the cleanData function, with a parameter to turn it on and off. But really need to revisit this later.

@kaijagahm
Copy link
Owner Author

ERASE ERASE--I have removed the downsampling (I think? Though I lost track of the PR where this happened, and it would be nice to dig it up). If I didn't get rid of it, let's get rid of it.

Instead, I'd like to formally implement the downsampling code used here, or similar, as a function in the vultureUtils package. Should be fairly straightforward to do, but need to add argument checks etc.

# Downsample the data and save the downsampled data
subsample <- function(df, idCol = "Nili_id", timestampCol = "timestamp", mins = 10){
  sub <- df %>%
    arrange(idCol, timestampCol) %>%
    group_by(.data[[idCol]]) %>%
    mutate(tc = cut(.data[[timestampCol]], 
                    breaks = paste(as.character(mins), "min", sep = " "))) %>%
    group_by(.data[[idCol]], 
             "d" = lubridate::date(.data[[timestampCol]]), tc) %>%
    slice(1) %>%
    ungroup() %>%
    dplyr::select(-c("d", "tc"))
  return(sub)
}

@kaijagahm
Copy link
Owner Author

Note to self: might need to update the code in light of changes made to the data prep script.

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

No branches or pull requests

1 participant