5.2.pems.tidyverse.tools {pems.utils}R Documentation

Functions to use tidyverse code with pems.utils outputs

Description

Various codes and methods.

Usage


#pems object methods

#dplyr (1) standard methods
## S3 method for class 'pems'
select(.data, ...)
## S3 method for class 'pems'
rename(.data, ...)
## S3 method for class 'pems'
filter(.data, ...)
## S3 method for class 'pems'
arrange(.data, ...)
## S3 method for class 'pems'
slice(.data, ...)
## S3 method for class 'pems'
mutate(.data, ..., units=NULL, warn=TRUE)
## S3 method for class 'pems'
group_by(.data, ..., add=FALSE)
## S3 method for class 'pems'
groups(x)
## S3 method for class 'pems'
ungroup(x, ...)
## S3 method for class 'pems'
group_size(x)
## S3 method for class 'pems'
n_groups(x)
## S3 method for class 'pems'
summarise(.data, ...)
## S3 method for class 'pems'
pull(.data, ...)

#dplyr (2) related underscore methods
## S3 method for class 'pems'
select_(.data, ..., warn=TRUE)
## S3 method for class 'pems'
rename_(.data, ..., warn=TRUE)
## S3 method for class 'pems'
filter_(.data, ..., warn=TRUE)
## S3 method for class 'pems'
arrange_(.data, ..., warn=TRUE)
## S3 method for class 'pems'
slice_(.data, ..., warn=TRUE)
## S3 method for class 'pems'
mutate_(.data, ..., units=NULL, warn=TRUE)
## S3 method for class 'pems'
group_by_(.data, ..., add=FALSE, warn=TRUE)             
## S3 method for class 'pems'
summarise_(.data, ..., warn=TRUE)

#dplyr (3) joining methods
## S3 method for class 'pems'
inner_join(x, y, by = NULL, copy = FALSE, ...)
## S3 method for class 'pems'
left_join(x, y, by = NULL, copy = FALSE, ...)
## S3 method for class 'pems'
right_join(x, y, by = NULL, copy = FALSE, ...)
## S3 method for class 'pems'
full_join(x, y, by = NULL, copy = FALSE, ...)
## S3 method for class 'pems'
semi_join(x, y, by = NULL, copy = FALSE, ...)
## S3 method for class 'pems'
anti_join(x, y, by = NULL, copy = FALSE, ...)

Arguments

.data

(pems.object) The pems object to be used with, e.g. dplyr code.

...

(Optional) Other arguments, currently all passed on to equivalent tridyverse function or method.

warn

(Optional) Give warnings? For an underscore methods: a warning that an underscore method was used (See Below). For mutate: if new elements are generated within unit assignments.

units

(Character) In mutate, the units to assign to new elements created by call. See Below.

x

(Various) For group... functions, an object of grouped_df class. For ...join functions, the first of two datasets, typically a pems object or data.frame, to be joined together.

add

(Optional) Argument used by group_by and related dplyr grouping functions.

y, by, copy

(various) For ...join functions, consistent with dplyr, y is the second of two datasets, typically a pems object or data.frame, to be joined together, the first being x, and by and copy are optional arguments. See below.

Details

The pems object methods select, rename, filter, arrange, slice, mutate, group_by and summarise are similar to data.frame methods of the same names in dplyr, but (hopefully) they also track units, etc, like a pems object. Work in progress. See below, especially Note.

Equivalent underscore methods (select_, etc) are also provided, although it should be noted that their future in dplyr itself is not certain.

Data joining methods include inner_join, left_join, right_join, full_join, semi_join and anti_join. Like above these are similar data.frame equivalents in dplyr, but (hopefully) also track units, etc, like a pems object. Same 'work in progress' caveat. See below.

Value

select returns the requested part of the supplied pems object, e.g.: select(pems.1, velocity) returns the velocity element of pems.1 as a single column pems.object, consistent with the data.frame handling of select.data.frame.

rename returns the supplied pems object with the requested name change, e.g.: rename(pems.1, speed=velocity) returns pems.1 with the velocity column renamed speed.

filter returns the supplied pems object after the requested filter operation, e.g.: filter(pems.1, velocity>0.5) returns pems.1 after excluding all rows where the velocity value was less than or equal to 0.5.

arrange returns the supplied pems object reordered based on order of values in an identified element, e.g.: arrange(pems.1, velocity) returns pems.1 with its row reordered lowest to highest velocity entry.

slice returns requested rows of the supplied pems object, e.g.: slice(pems.1, 1:10) returns rows 1 to 10 of pems.1 as a new pems object.

mutate returns the supplied pems object with extra elements calculated as requested, e.g.: mutate(pems.1, new=velocity*2) returns the pems object with additional column, called new, which is twice the values in the velocity column. The units of the new column can be set using the additional argument units, e.g. mutate(pems.1, new=velocity*2, units="ick").

group_by returns a grouped_df object. [to document]

summarise [to document]

The ..._join joining methods, join to supplied datasets. The first, x, must be a pems to employ ..._join.pems by the second, y can be e.g. a data.frame, etc. [rest to document... link to dplyr and vignette]

Warning

This currently work in progress - handle with care.

Note

Currently not sure what I think about tidyverse, but it is always interesting, and ideas like fortify are really nice.

Author(s)

Karl Ropkins

References

Generics in general:

H. Wickham. Advanced R. CRC Press, 2014.

(Not yet fully implemented within this package.)

ggplot2:

H. Wickham. ggplot2: elegant graphics for data analysis. Springer New York, 2009.

(See Chapter 9, section 9.3, pages 169-175, for discussion of fortify)


[Package pems.utils version 0.2.27.4 Index]