Description Usage Arguments Value Author(s) See Also Examples
View source: R/fdbk_asdataframe.R
Other way to perform a binning like in function fdbk_dt_binning but by defining levels around which to bin instead of the bins limits. The limits of the bins will be calculated by taking the mean between neighbouring levels. The two functions differ in the sense that fdbk_dt_binning allow to have gaps between the bins, whereas the bins will be continuous in fdbk_dt_binning_level. This function allows to have non-equally spaced levels without gaps between the bins, so that the level is not always at the center of the bin.
1 | fdbk_dt_binning_level(DT, varToBin = "level", levels, includeAll = FALSE)
|
DT |
data.table |
varToBin |
variable that should be binned (and will be replaced by the binned version) |
levels |
number/vector of levels on which the bins will be defined |
Logical |
to include data that are out of the bins defined by levels. If set to FALSE (default), data that falls out of the bins are dicarded. If set to true, the numerically lower and upper limits will be set to -Inf and +Inf, respectively. This allows to keep data that falls out of the bins. |
data.table with varToBin replaced by factorized mid-bin values (NA if variable falls in none of the bins)
Felix <felix.fundel@dwd.de>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #plot scores accross binned levels
require(ggplot2)
fnames = "~/examplesRfdbk/icon/temp/verTEMP.2014120112"
cond = list(obs="!is.na(obs)",varno="varno%in%c(2,3,4,29)")
columnnames = c("obs","veri_data","varno","state","level")
DT = fdbk_dt_multi_large(fnames,cond,columnnames,1)
levels = c(100000,92500,85000,70000,60000,50000,40000,30000)
DT = fdbk_dt_binning_level(DT,"level",levels)
DT$varno = varno_to_name(DT$varno)
strat = c("varno","level")
scores = fdbk_dt_verif_continuous(DT,strat)
setkey(scores,scorename,varno,level)
scores = scores[!is.na(scores),]
p = ggplot(scores,aes(x=scores,y=level,group=interaction(varno,scorename)))+
geom_path() + facet_wrap(~varno~scorename,scales="free_x",ncol = 6)+
theme_bw()+theme(axis.text.x = element_text(angle=70,hjust = 1))+scale_y_reverse()
p
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.