xtsubset: Subset a data frame while preserving its 'xtdata' attribute

Description Usage Arguments Details Value Author(s) See Also Examples

Description

A wrapper of the subset function that preserves the xtdata attribute.

Usage

1
2

Arguments

data

a data frame with the xtdata attribute

formula

a logical formula to subset to.

select

the names of the variables to keep.

drop

passed on to [ indexing operator.

...

other methods passed to subset

Details

The method is explained at https://github.com/hadley/devtools/wiki/Computing-on-the-language#non-standard-evaluation-in-subset.

Value

a data frame

Author(s)

Francois Briatte f.briatte@ed.ac.uk

See Also

xtdata, subset

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Load QOG demo datasets.
data(qog.demo)
# Subset to two countries.
QOG = xtsubset(qog.ts.demo, cname %in% c("China", "India"))
if(require(ggplot2)) {
  # Plot log-population curves.
  qplot(data = QOG, y = unna_pop, x = year, colour = cname, geom = "step") +
    scale_colour_brewer(palette = "Set1") +
    scale_y_log10()
}

briatte/qogdata documentation built on May 13, 2019, 7:43 a.m.