Question: I am trying to create a function in R that turns the colors of a plot into colors that are colorblind friendly. According to my
I am trying to create a function in R that turns the colors of a plot into colors that are colorblind friendly. According to my assignment, the function should perform an operation that solves a specific problem that you can and will demonstrate using multiple coding examples. You will be graded on how integrative your function is; do you combine multiple concepts to solve a problem? A function doing simple math eg adding one to a number will not be deemed acceptable.
Your function should have at least two arguments. Your function must include and demonstrate competency in more than one of these topics.
operators
the family of dplyr data wrangling functions in the tidyverse
the pipe operator
ggplot data visualization in the tidyverse
joining data
pivoting data
grouping data
iteration for loops or sapply and lapply
dataframes, vectors, and lists
My code is as follows:
colorblindfriendlyplot functionplot palette "viridis"
libraryggplot
libraryviridis
data ggplotbuildplot$data
uniquecolors uniqueunlistlapplydata functionx x$fill
colors viridispalpaletten lengthuniquecolors
plot plot
scalefillmanualvalues colors
scalecolormanualvalues colors
returnplot
However, I keep getting the error "Error in grDevices::rgbcols cols cols alpha alpha : alpha level NA not in when I try to run my code using an example. Does anyone have any suggestions on how to fix my code?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
