Learn R Programming

zfit (version 0.1.0)

zprint: Print the result of a function in a pipe but return original object

Description

This function passes x to f and prints the result, but then returns the original x. It is useful in a pipe, when one wants a to print the derivative of an object in the pipe but then return or assign the original object. An example is printing the summary() of an estimated model but

Usage

zprint(x, f, ...)

Arguments

x

An object, typically in a pipe

f

A function to be applied to x before printing

...

Other arguments to be passed to f

Value

The original object x

See Also

Other zfit: zglm(), zlm(), zlogit(), zprobit()

Examples

Run this code
# NOT RUN {
m <- lm( speed ~ dist, cars) %>%
  zprint(summary) # prints summary(x)
m                 # m is the original model object

if(require("dplyr")) {
  cw_subset <- chickwts %>%
    zprint(count, feed, sort=TRUE) %>% # prints counts by feed
    filter(feed=="soybean")
  cw_subset # cw_subset is ungrouped, but filtered by feed
}

# }

Run the code above in your browser using DataLab