df_color: Appends a column to a data frame containing hex codes (ready...

Description Usage Arguments Value Examples

Description

Appends a column to a data frame containing hex codes (ready for usage in a plot) The values are determined by a user-specified column.

Usage

1
2
df_color(df, column, output_name = "color", min_color = "green",
  max_color = "red", method = "hsv", smooth_factor = 2)

Arguments

df

Data frame containing the original data.

column

A string containing the name of the column that will determine color.

output_name

Name for the column in which the output will be stored. Defaults to "color"

min_color

Color to be assigned to the row with the lowest value. Defaults to green.

max_color

Color to be assigned to the row with the highest value. Defaults to red.

method

Type of gradient. Allows both "rgb" and "hsv". Defaults to "hsv"

smooth_factor

Parameter "smooth_factor" for "rgb_weighted_mean" call

Value

A data frame identical to df, except for an extra column (whose name is given by output_name) containing hexcodes

Examples

1
2
3
plot(mtcars$hp, mtcars$disp, col=df_color(mtcars, "wt")$color, pch=18, cex=1.5)
plot(mtcars$hp, mtcars$disp, col=df_color(mtcars, "wt", min_color="darkblue", max_color="darkred")$color, pch=18, cex=1.5)
plot(mtcars$hp, mtcars$disp, col=df_color(mtcars, "wt", min_color="darkblue", max_color="darkred", method="rgb", smooth_factor=1)$color, pch=18, cex=1.5)

dpcarballo/coloR documentation built on June 1, 2019, 8:14 p.m.