0
0
R Programmingprogramming~10 mins

Coordinate systems 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 base R with x and y coordinates.

R Programming
plot(x, y, type = [1])
Drag options to blanks, or click blank then click option'
A"p"
B"l"
C"h"
D"b"
Attempts:
3 left
💡 Hint
Common Mistakes
Using type = "l" which draws lines instead of points.
Forgetting to put quotes around the type value.
2fill in blank
medium

Complete the code to convert Cartesian coordinates (x, y) to polar coordinates (r, theta).

R Programming
r <- sqrt([1]^2 + y^2)
Drag options to blanks, or click blank then click option'
Ax
Btheta
Cr
Dsin
Attempts:
3 left
💡 Hint
Common Mistakes
Using theta instead of x in the formula.
Confusing the radius r with the angle theta.
3fill in blank
hard

Fix the error in the code to calculate the angle theta in radians from Cartesian coordinates.

R Programming
theta <- atan2(y, [1])
Drag options to blanks, or click blank then click option'
Ar
Bsin
Cx
Dcos
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of x and y in atan2.
Using trigonometric functions like sin or cos incorrectly.
4fill in blank
hard

Fill both blanks to create a data frame with polar coordinates from Cartesian vectors x and y.

R Programming
polar_coords <- data.frame(r = sqrt(x[1] + y[2]))
Drag options to blanks, or click blank then click option'
A^2
B+
C*2
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication *2 instead of exponentiation.
Using subtraction instead of addition.
5fill in blank
hard

Fill all three blanks to convert polar coordinates (r, theta) back to Cartesian coordinates (x, y).

R Programming
x <- [1] * cos([2])
y <- [3] * sin(theta)
Drag options to blanks, or click blank then click option'
Ar
Btheta
Dx
Attempts:
3 left
💡 Hint
Common Mistakes
Using x instead of r in the formulas.
Swapping r and theta in the function arguments.