View source: R/compare_classifications.R
compare_classifications | R Documentation |
this function takes multiple classifications of the same data and compares the agreement between each, on a timepoint level.
compare_classifications(date, classifications)
date |
datetime in POSIXCT format. See hoopoe$activity$date for example |
classifications |
a dataframe containing the results from different classifications in each column. The classifications must correspond to the same datetimes. |
a dataframe containing date
the raw classifications
each state with the number of times it was used in a classification
whether or not all classes provided the same state
## Not run:
# Import data
data(hoopoe)
start = as.POSIXct("2016-07-01","%Y-%m-%d", tz="UTC")
end = as.POSIXct("2017-06-01","%Y-%m-%d", tz="UTC")
PAM_data= create_crop(hoopoe,start,end)
# perform one classification using classifyFLAP
classification = classify_flap(dta = PAM_data$acceleration, period = 12)
# Put the classification in the same resolution as pressure
class1 = create_merged_classification(from = classification$timetable$start,
to = classification$timetable$end,
# because the timetable only contains migration periods
classification = rep_len(1,length(classification$timetable$end)),
add_to = PAM_data$pressure)
# Convert to categories
class1 = ifelse(class1 == classification$migration, "Migration", "Other")
# Perform another classification using pressure difference
class2 = c(0,ifelse(abs(diff(PAM_data$pressure$obs))>2, "Migration", "Other"))
# both classes have been converted to the same time intervals as pressure,
date = PAM_data$pressure$date
# Combine the classifications into a dataframe
classifications = data.frame(flap = class1, # flapping classification
Pdiff = class2) # pressure difference classification
class_comparison = compare_classifications(date=date,
classifications=classifications)
plot(PAM_data$pressure$date,
PAM_data$pressure$obs,
type = "l",
xlab = "Date",
ylab = "Pressure (hPa)",
col = "royalblue3")
points(PAM_data$pressure$date,
PAM_data$pressure$obs,
cex = class_comparison$Migration / 2,
col ="orange",
pch = 16)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.