0
0
R Programmingprogramming~10 mins

Saving plots (ggsave) 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 save the plot as a PNG file.

R Programming
ggsave(filename = [1], plot = p)
Drag options to blanks, or click blank then click option'
A"p.png"
B"plot.png"
Cp.png
Dplot.png
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename
Using a variable name instead of a string
2fill in blank
medium

Complete the code to save the plot with a width of 6 inches.

R Programming
ggsave(filename = "plot.png", plot = p, width = [1])
Drag options to blanks, or click blank then click option'
A"6"
B6
C5
D8
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number 6 in quotes
Using the wrong number for width
3fill in blank
hard

Fix the error in the code to save the plot as a PDF file.

R Programming
ggsave(filename = [1], plot = p, device = "pdf")
Drag options to blanks, or click blank then click option'
A"plot.pdf"
Bplot.pdf
C"plot.png"
Dpdf
Attempts:
3 left
💡 Hint
Common Mistakes
Using filename without quotes
Using the wrong file extension
4fill in blank
hard

Fill both blanks to save the plot with height 4 inches and resolution 300 dpi.

R Programming
ggsave(filename = "plot.png", plot = p, height = [1], dpi = [2])
Drag options to blanks, or click blank then click option'
A4
B300
C6
D72
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing dpi with height
Using dpi values that are too low
5fill in blank
hard

Fill all three blanks to save the plot as a JPEG with width 5 inches and quality 90.

R Programming
ggsave(filename = [1], plot = p, width = [2], quality = [3], device = "jpeg")
Drag options to blanks, or click blank then click option'
A"plot.jpg"
B5
C90
D"plot.jpeg"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong file extension
Putting numbers in quotes
Confusing quality with dpi