Description Usage Arguments Examples
The function receives a numerical data stream and computes its outliers. The Quality of such stream is defined as Q = 1 - percentage of outliers.
1 | streamQ(datastream)
|
datastream |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (datastream)
{
df <- jsonlite::stream_in(url(datastream))
dfjson <- jsonlite::fromJSON(jsonlite::toJSON(df))
mydata <- dfjson$nameValuePairs
columnnames <- colnames(mydata)
x <- data.frame(mydata$inDateTime$nameValuePairs)
tempout_index <- grep(columnnames[grepl("temperature_indoor",
columnnames)], colnames(mydata))
xy <- data.frame(x, mydata[tempout_index])
xy <- na.omit(xy)
colnames(xy) <- c("time", "tempout")
summary(xy)
xy = xy[1:3, ]
dat.ts <- ts(xy$tempout, frequency = 1)
data.ts.outliers <- tso(dat.ts, types = c("AO", "LS", "TC",
"IO", "SLS"))
Q = 1 - nrow(data.ts.outliers$outliers)/nrow(xy)
return(Q)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.