Description Usage Arguments Value Examples
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.
1 2 |
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 |
A data frame identical to df, except for an extra column (whose name is given by output_name) containing hexcodes
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.