select: Functional select

Description Usage Arguments Value Author(s) Examples

Description

select whatExpression by byExpression from d where whereExpression order of evaluation from, where, by, what

Usage

1
select(d, where = NULL, by = NULL, what = NULL)

Arguments

d

A dataframe

where

A list of constraints expressions evaluating to booleans

by

A list of groupby expression

what

A list of aggregate expressions

Value

A dataframe

Author(s)

JFP

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
d <- data.frame(
    date=seq(as.Date("2001-01-01"), as.Date("2001-12-01"), by="month"),
    ticker=sample(c("1 HK", "2 HK"), 12, TRUE),
    return=rnorm(12)
  )
d %>% select(by=list(ticker=expression(ticker))) # defaut by to take last
d %>% select(by=list(ticker=expression(ticker)),
               what=list(m=expression(mean(return)),s=expression(sd(return))))
d %>% update(by=list(ticker=expression(ticker)),
               what=list(m=expression(mean(return)),s=expression(sd(return))))
d %>% select(where=list(expression(return>0)),
               by=list(ticker=expression(ticker)),
               what=list(m=expression(mean(return)),s=expression(sd(return))))
d %>% update(where=list(expression(return>0)),
               by=list(ticker=expression(ticker)),
               what=list(m=expression(mean(return)),s=expression(sd(return))))
d %>% update(where=list(expression(return>0)), 
               by=list(ticker=expression(ticker)), 
               what=list(m=expression(mean(return)),s=expression(sd(return))))

HikaGenji/fql documentation built on April 12, 2021, 8:36 a.m.