latticeExtra: Interfaces for latticeExtra package for data science...

Description Usage Arguments Details Value Author(s) Examples

Description

Interfaces to latticeExtra functions that can be used in a pipeline implemented by magrittr.

Usage

1
2
3
4
5

Arguments

data

data frame, tibble, list, ...

...

Other arguments passed to the corresponding interfaced function.

Details

Interfaces call their corresponding interfaced function.

Value

Object returned by interfaced function.

Author(s)

Roberto Bertolusso

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
## Not run: 
library(intubate)
library(magrittr)
library(latticeExtra)


## ntbt_ecdfplot: Trellis Displays of Empirical CDF
data(singer, package = "lattice")

## Original function to interface
ecdfplot(~height | voice.part, data = singer)

## The interface puts data as first parameter
ntbt_ecdfplot(singer, ~height | voice.part)

## so it can be used easily in a pipeline.
singer %>%
  ntbt_ecdfplot(~height | voice.part)


## ntbt_mapplot: Trellis displays on Maps a.k.a. Choropleth maps
library(maps)
library(mapproj)
data(USCancerRates)

## Original function to interface
## Note: Alaska, Hawaii and others are not included in county map;
## this generates warnings with both USCancerRates and ancestry.
suppressWarnings(print(
  
  mapplot(rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
          data = USCancerRates,
          map = map("county", plot = FALSE, fill = TRUE,
                    projection = "mercator"))
  
))

## The interface puts data as first parameter
suppressWarnings(print(
  
  ntbt_mapplot(USCancerRates, rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
               map = map("county", plot = FALSE, fill = TRUE,
                         projection = "mercator"))

  ))

## so it can be used easily in a pipeline.
suppressWarnings(print(
  
  USCancerRates %>%
  ntbt_mapplot(rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
               map = map("county", plot = FALSE, fill = TRUE,
                         projection = "mercator"))

  ))


## ntbt_rootogram: Trellis Displays of Tukey's Hanging Rootograms
library(lattice)
dta <- data.frame(x = rpois(1000, lambda = 50))

## Original function to interface
rootogram(~x, data = dta, dfun = function(x) dpois(x, lambda = 50))

## The interface puts data as first parameter
ntbt_rootogram(dta, ~x, dfun = function(x) dpois(x, lambda = 50))

## so it can be used easily in a pipeline.
dta %>%
  ntbt_rootogram(~x, dfun = function(x) dpois(x, lambda = 50))


## ntbt_segplot: Plot segments using the Trellis framework
data(USCancerRates)

## Original function to interface
segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male,
        data = subset(USCancerRates, state == "Washington"))

## The interface puts data as first parameter
ntbt_segplot(subset(USCancerRates, state == "Washington"),
             reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male)

## so it can be used easily in a pipeline.
subset(USCancerRates, state == "Washington") %>%
  ntbt_segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male)

USCancerRates %>%
  subset(state == "Washington") %>%
  ntbt_segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male)


## ntbt_tileplot: Plot a spatial mosaic from irregular 2D points
tmp <- state.center
tmp$Income <- state.x77[,"Income"]
library(deldir)

## Original function to interface
tileplot(Income ~ x * y, tmp, border = "black",
         panel = function(x, y, ...) {
           panel.voronoi(x, y, ..., points = FALSE)
           panel.text(x, y, state.abb, cex = 0.6)
         })

## The interface puts data as first parameter
ntbt_tileplot(tmp, Income ~ x * y, border = "black",
              panel = function(x, y, ...) {
                panel.voronoi(x, y, ..., points = FALSE)
                panel.text(x, y, state.abb, cex = 0.6)
              })

## so it can be used easily in a pipeline.
tmp %>%
  ntbt_tileplot(Income ~ x * y, border = "black",
                panel = function(x, y, ...) {
                  panel.voronoi(x, y, ..., points = FALSE)
                  panel.text(x, y, state.abb, cex = 0.6)
                })

## End(Not run)

rbertolusso/intubate documentation built on May 27, 2019, 3 a.m.