Skip to content

Instantly share code, notes, and snippets.

@tehp
Created March 1, 2020 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tehp/eae291998532849490efb4774620cb68 to your computer and use it in GitHub Desktop.
Save tehp/eae291998532849490efb4774620cb68 to your computer and use it in GitHub Desktop.
points <- 0
window_size <- 7
acceptable_difference <- 0.65
windows = array()
for(i in 0:(nrow(week_data) - window_size - 1)) {
window_sum <- 0
for(j in 0:(window_size)) {
window_sum <- (window_sum + week_data$Global_active_power[i + j])
}
windows[i] = window_sum/window_size
}
for(i in 0:(length(windows) - window_size)) {
difference <- (abs(windows[i] - windows[i+1]))
if (isTRUE(difference > acceptable_difference)) {
print("Point of anomoly found at window:")
print(i)
print(week_data[i,])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment