## Thursday, June 04, 2015

### Color/colour band combination generator in R

Last time I did color band combinations I made a spreadsheet in Excel.  This time around I wrote a quick R script that generates the combos much more efficiently.  There is a SAS program available to generate color band combinations as well.  I've never tried it, but if you have more complex needs and SAS is available to you it looks great.  We just needed two colors on one leg so my R script does just as nicely for the simpler case.

#Color key:
#Red-R
#Orange-O
#Yellow-Y
#MediumGreen-G
#MediumBlue-B
#LightBlue-L
#White-W
#Gray-E
#Black-K

colours<-c("K","E","B","G",
"O","R","W","Y", "L")

library(gtools)
#get all permutations
bandcombos<-permutations(n=9,r=2,v=colours,repeats.allowed=TRUE)
#n= number of colors, r=how many are adjacent, v= the vector of colors
#I allow repeats because I'm okay with two colors together (yellow over yellow, for example).

nrow(permutations(n=9,r=2,v=colours,repeats.allowed=TRUE))
#count how many combinations you've made.

write.csv(bandcombos, file="yourproject_bandcombos.csv")
#Take your file and you can open it in a spreadsheet program or wherever for further formatting/use.
#We specified our bands would go on the left leg, so you could reuse all these combinations
#for the right leg.

1. Great resource, thanks so much!

2. Hi Claire! Awesome, so glad I googled "get bird banding combinations easily"!