I am new to programming and coding, trying to learn R in the Google course.
They have given several examples for visuals using the ggplot functions, but they have used the aes() in two ways.
First:
ggplot(data=palmerpenguins) + geom_point(mapping = aes(x = bill_length_mm,y = body_mass_g)) The aes() function is inside the geom_point() function.
Then they show: ggplot(data, aes(x=distance, y= dep_delay, color=carrier, size=air_time, shape = carrier)) + geom_point()
Now the aes() function is in the ggplot() function, where they specify the dataset.
What is the reason for the switch? It seems like aes() can go in either place. Is this true? For something that is so specific like coding, it's confusing why you could do it either way. Any explanation would be appreciated. Thanks
