Learn R Programming

m61r (version 0.0.3)

mutate: Mutate and transmutate a data.frame

Description

Mutate and transmutate a data.frame.

Usage

mutate_(df, ...)

transmutate_(df, ...)

Arguments

df

data.frame

...

formula used for mutating/transmutating the data.frame

Value

The functions return a data frame. The output has the following properties:

  • For function mutate_(), output includes all df columns. In addition, new columns are created according to argument ... and placed after the others.

  • For function transmutate_(), output includes only columns created according to argument ... and placed after the others.

Examples

Run this code
# NOT RUN {
tmp <- mutate_(CO2,z=~conc/uptake)
head(tmp)

# Return an warning: expression mean(uptake) get a result with 'nrow' different from 'df'
# tmp <- mutate_(CO2,mean=~mean(uptake))

tmp <- mutate_(CO2,z1=~uptake/conc,y=~conc/100)
head(tmp)

tmp <- transmutate_(CO2,z2=~uptake/conc,y2=~conc/100)
head(tmp)
# }

Run the code above in your browser using DataLab