Description Usage Arguments Value Author(s) See Also Examples
View source: R/fdbk_asdataframe.R
Bin a data.table column into user defined bins and replace it with the bin center value. If breaks can be provided (e.g. no gaps between bins) try to use 'cut' instead.
1 | fdbk_dt_binning(DT, varToBin = "level", binLower, binUpper)
|
DT |
data.table |
varToBin |
variable that should be binned (and will be replaced by the binned version) |
binLower |
number/vector lower bins limits |
binUpper |
number/vector upper bins limits |
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 18 19 | #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)
binUpper = seq(100000,1000,by=-5000)+1500
binLower = seq(100000,1000,by=-5000)-1500
DT = fdbk_dt_binning(DT,"level",binLower,binUpper)
DT = DT[!is.na(level),,]
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.