Rainar Angelo

View Original

Day 4: Plotting using colour and shapes

"These Penguins Are Large"


World-class analysis from my friend and SO earlier today.

She wanted credit for it however... so here I am giving her credit 😆

This did raise an important point on the output of our code from yesterday

ggplot(data=penguins,
   mapping=aes(x=flipper_length_mm,y=body_mass_g))+
geom_point()

We ran this code and got the output:

However... the graph that resulted in the aforementioned world-class analysis was not the same

The graph above? 

Black and white, same shapes and doesn't tell you ANYTHING about the specific species of the penguins

So let's fix that!

The data set we're using, Palmer Penguins, has 3 types of species.

When you use the code view(penguins) and hit enter, you can see them under the species column

Let's identify them on the graph

In addition to the code yesterday (additional parts in bold):

ggplot(data=penguins,
    mapping=aes(x = flipper_length_mm,y = body_mass_g, colour =       species, shape = species))+
geom_point()

Colour = species --> Attributes colour to the species
Shape = species --> Attributes different shapes to the species

When you run this code, your output should look like this: 

As you can see...

"These Penguins Are indeed Large"

It's simple analysis to begin with but, hey, be proud of being able to run this code in less than a week into R.

p.s.

Small assignment for you:

What's your interpretation of this graph? 👀

Reply with your answer 

(bet you'll get it wrong 🐧)