0
0
R Programmingprogramming~10 mins

Scatter plots (geom_point) in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a scatter plot using ggplot2.

R Programming
ggplot(data = mtcars, aes(x = wt, y = mpg)) + geom_[1]()
Drag options to blanks, or click blank then click option'
Apoints
Bpoint
Cgeom_point
Dgeom_points
Attempts:
3 left
💡 Hint
Common Mistakes
Writing the full function name 'geom_point' inside the blank causes syntax error.
Using 'points' or 'geom_points' which are not valid ggplot2 functions.
2fill in blank
medium

Complete the code to map the color aesthetic to the 'cyl' variable.

R Programming
ggplot(mtcars, aes(x = wt, y = mpg, color = [1])) + geom_point()
Drag options to blanks, or click blank then click option'
Acyl
Bmpg
Cwt
Dgear
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mpg' or 'wt' which are mapped to x and y axes, not color.
Using 'gear' which is unrelated to this color mapping.
3fill in blank
hard

Fix the error in the code by completing the function name correctly.

R Programming
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_[1]()
Drag options to blanks, or click blank then click option'
Ageom_point
Bpoints
Cgeom_points
Dpoint
Attempts:
3 left
💡 Hint
Common Mistakes
Including 'geom_' inside the blank causes syntax errors.
Using plural forms like 'points' or 'geom_points' which are invalid.
4fill in blank
hard

Fill both blanks to create a scatter plot with size mapped to 'hp' and shape mapped to 'cyl'.

R Programming
ggplot(mtcars, aes(x = wt, y = mpg, size = [1], shape = [2])) + geom_point()
Drag options to blanks, or click blank then click option'
Ahp
Bmpg
Ccyl
Dwt
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up variables or using x/y variables for size or shape.
Using variables not present in mtcars.
5fill in blank
hard

Fill all three blanks to create a scatter plot with color mapped to 'gear', size to 'hp', and shape to 'cyl'.

R Programming
ggplot(mtcars, aes(x = wt, y = mpg, color = [1], size = [2], shape = [3])) + geom_point()
Drag options to blanks, or click blank then click option'
Acyl
Bhp
Cgear
Dmpg
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable for multiple aesthetics.
Using variables not in the mtcars dataset.