title: Coloring Data points by categorical variable
body: <p>I am new to R, so my problem is simple. I am trying to create a scatterplot that shows data about all countries, and then size the bubbles by population and color them by region. I have accomplished everything except the coloring. 
  Here is my code:</p>
  
  <pre><code>attach(gapminder2)
  colors(distinct = FALSE)
  radius&lt;-sqrt(gapminder2$Population/pi)
  plot(log(`CO2 Emissions per capita`), log(Income), main="PerCapita GDP vs CO2 Emissions by Country", xlab="CO2 Emissions (tons/person)", ylab="Per Capita GDP (US$)")
  grid()
  symbols(log(`CO2 Emissions per capita`), log(Income), main="PerCapita GDP vs CO2 Emissions by Country", xlab="CO2 Emissions (tons/person)", ylab="Per Capita GDP (US$)", circles=radius, inches=0.25)
  </code></pre>
  
  <p>All of that runs fine and produces the following graph:</p>
  
  <p><a href="https://i.stack.imgur.com/PrXmC.png" rel="nofollow noreferrer">GDP vs CO2 graph</a></p>
  
  <p>In the dataset (called "gapminder2"), I have a variable "Region". I have tried converting it to a factor variable (Region&lt;- as.factor) but i still don't know how to assign each individual region its own color on the graph (I have 8 different regions). </p>