Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started