comparableRows: Find comparable rows in DT for two or more attributes

Description Usage Arguments Value Author(s) Examples

View source: R/fdbk_asdataframe.R

Description

Find comparable rows in DT for two or more attributes

Usage

1
comparableRows(DT, splitCol, splitVal, compareBy)

Arguments

DT

data.table

splitCol

Dt column name that contains the attributes that should be compared

splitVal

two or more values of splitCol that should be compared

compareBy

other column names that should be used two decide if a comparable row exists for both splitVals

Value

indices of DT that show which rows should be retained (TRUE) i.e. rows that have a counterpart in each of the two splitVals

Author(s)

Felix <[email protected]>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Delete rows in DT that have no counterpart for GME/ICON concerning the attributes: "veri_forecast_time","veri_initial_date","varno","statid"

require(ggplot2)
fnames                = system("ls ~/examplesRfdbk/*/synop/verSYNOP.2014*",intern=T)
cond                  = list(varno="varno%in%c(3,29)",veri_description="grepl('forecast',veri_description)")
columnnames           = c("obs","veri_data","varno","veri_model","veri_forecast_time","veri_initial_date","obs_id")
DT                    = fdbk_dt_multi_large(fnames,cond,columnnames,20)
keepind               = comparableRows(DT,splitCol="veri_model",splitVal=unique(DT$veri_model),compareBy=c("obs","veri_forecast_time","veri_initial_date","varno","obs_id"))
DT                    = DT[keepind]
DT[,.N,by=c("varno","veri_model")]
DT$varno              = varno_to_name(DT$varno)
strat                 = c("varno","veri_forecast_time","veri_model")
scores                = fdbk_dt_verif_continuous(DT,strat)
p =  ggplot(scores,aes(x=veri_forecast_time,y=scores,group=interaction(scorename,varno,veri_model),colour = veri_model, linetype=varno))+
     geom_line(size=.7) + geom_point(size=1.5) + facet_wrap(~scorename, scales = "free")+
     theme_bw()+theme(axis.text.x  = element_text(angle=70,hjust = 1))
p

rfxf/Rfdbk documentation built on Dec. 17, 2018, 9:14 a.m.