I need assistance in creating a simple pie chart in the R tool in Alteryx.
My end goal is to create a Harvey ball where the 2 colors used are red and green. Red = loss and Green = Win. (example below)
The issue I am facing is that the R Tool is not recognizing my input for the Red and Green. It outputs the colors Orange and Blue instead. (Example below).
Here is my R Code:
df <- read.Alteryx("#1", mode="data.frame")
AlteryxGraph(2, width=2400, height=3000, res=300)
pie(df$Value, df$Name, main = "Banner1", col = df$Color)
invisible(dev.off())
Solved! Go to Solution.
Hi @agcruz
Are your color names in lower case as in this example from http://www.r-tutor.com/elementary-statistics/qualitative-data/pie-chart
> colors = c("red", "yellow", "green", "violet",
+ "orange", "blue", "pink", "cyan")
> pie(school.freq, # apply the pie function
+ col=colors) # set the color palette
Dan
I have used the lowercase text for the colors but still get the same error.
I got my code to work.
I figured out that I should an extra line in R to create a field with the color selection in stead of creating the field before the R tool. The code is below.
df <- read.Alteryx("#1", mode="data.frame")
AlteryxGraph(1, width=2400, height=3000, res=300)
df$color <- ifelse(df$ColorNumber == 1,"green3","red2")
pie(df$Value, df$Name, main = df$ChartTitle, col = df$color)
invisible(dev.off())
Thanks!