fdbk_dt_conditional: Function for conditional filtering of data.tables

Description Usage Arguments Value Author(s) Examples

View source: R/fdbk_asdataframe.R

Description

Helps to filter rows from data.tables with condition for the same column. A typical application would be to filter wind direction observations whenever wind speed is <3m/s In this case one would have to delete all varno==111 for all matching varn===112 that have obs less than 3m/s. This is complex, as observations of varno 111 and 112 are in different rows. Even more complicated fitering task, e.g. filtering a variable on more than one other variable, might require to call this function sepatately for each task.

Usage

1

Arguments

DT

the data.table

condition

logical condition as character string

on

logical condition(s) as character string

by

character vector of all column names that sould be used for the grouping

Value

the fitered data.table (column and row order is not preserved!)

Author(s)

Felix <felix.fundel@dwd.de>

Examples

1
2
3
4
# Data table with 3 different variables, random obseervations at each location 
DT = data.table(varno=c(1,1,1,2,2,3),obs=c(1,2,3,0,1,4),lat=c(10,20,30,10,20,10),lon=c(5,6,7,5,6,8))
# Remove all variables 1 where for variable 2 obs>0. If variable 1 has no observation of variable 2 it is omitted as well.
fdbk_dt_conditional(DT,condition="varno==1",on="varno==2 & obs>0",by=c("lon","lat"))

rfxf/Rfdbk documentation built on May 27, 2019, 7:22 a.m.