Challenge - 5 Problems
Color Scale Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a basic colorRampPalette function
What is the output of this R code snippet?
R Programming
pal <- colorRampPalette(c("red", "blue")) colors <- pal(3) print(colors)
Attempts:
2 left
💡 Hint
colorRampPalette creates a gradient of colors between the given colors.
✗ Incorrect
colorRampPalette interpolates colors between red (#FF0000) and blue (#0000FF). For 3 colors, the middle color is the average, which is purple (#800080).
🧠 Conceptual
intermediate2:00remaining
Understanding colorRamp vs colorRampPalette
Which statement correctly describes the difference between colorRamp and colorRampPalette in R?
Attempts:
2 left
💡 Hint
Think about what type of output each function produces.
✗ Incorrect
colorRamp returns a function that gives numeric RGB values between colors, while colorRampPalette returns a function that produces hex color strings suitable for plotting.
❓ Predict Output
advanced2:00remaining
Output of a custom palette with transparency
What is the output of this R code?
R Programming
pal <- colorRampPalette(c("#FF000080", "#0000FF80"), alpha = TRUE) colors <- pal(2) print(colors)
Attempts:
2 left
💡 Hint
Check how colorRampPalette handles alpha transparency in hex colors.
✗ Incorrect
colorRampPalette preserves the alpha transparency in hex colors when generating the palette.
❓ Predict Output
advanced2:00remaining
Number of colors generated by brewer.pal
What is the length of the vector returned by brewer.pal(5, "Set1") in R?
R Programming
library(RColorBrewer) colors <- brewer.pal(5, "Set1") length(colors)
Attempts:
2 left
💡 Hint
brewer.pal returns the number of colors requested up to the palette maximum.
✗ Incorrect
brewer.pal(5, "Set1") returns exactly 5 colors from the Set1 palette.
🔧 Debug
expert2:00remaining
Identify the error in this colorRampPalette usage
What error does this R code produce?
R Programming
pal <- colorRampPalette(c(123, 456)) colors <- pal(3) print(colors)
Attempts:
2 left
💡 Hint
Check the input types for colorRampPalette.
✗ Incorrect
colorRampPalette expects a character vector of colors; numeric values cause an error.