df_color3: Appends a column named "color" to a data frame containing hex...

Description Usage Arguments Value Examples

Description

Appends a column named "color" to a data frame containing hex codes (ready for usage in a plot) Three different columns from a data frame provide amounts for red, green and blue light, which combine into a color for each observation, thus allowing the user to represent simultaneaously up to three columns using color. Darker/lighter colors represent simultaneous low/high values for all values. Red/green/blue-ish colors represent high values in column1/2/3, but low ones in the remaining. Cyan/magenta/yellow-ish colors represent low values in column1/2/3, but high ones in the remaining.

Usage

1
2
df_color3(df, column1, column2, column3, output_name = "color",
  avoid_white = TRUE)

Arguments

df

Data frame containing the original data.

column1

A string containing the name of the column that will determine the output's amount of red light

column2

A string containing the name of the column that will determine the output's amount of green light.

column3

A string containing the name of the column that will determine the output's amounto of blue light.

output_name

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

avoid_white

When set to TRUE, corrects colors that would be hard to distinguish in a white background.

Value

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

Examples

1
2
plot(mtcars$hp, mtcars$disp, col=df_color3(mtcars, "drat", "wt", "mpg")$color, pch=18, cex=1.5)
plot(mtcars$hp, mtcars$disp, col=df_color3(mtcars, "drat", "wt", "mpg", avoid_white=FALSE)$color, pch=18, cex=1.5)

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