LoslegenKostenlos loslegen

Graphics/

When generating graphics, you should make sure you use relative paths.

The code you're provided with represents a script in the R/ directory.

Diese Übung ist Teil des Kurses

Defensive R Programming

Kurs anzeigen

Anleitung zur Übung

  • Change the read_csv() argument to use relative paths.
  • Change the ggsave() argument to use relative paths.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

library("ggplot2")
library("readr")

# Show the file/directory structure
list.files(".")

# Change to relative paths and load the data
battles <- read_csv("/home/repl/survival/input/battles.csv")
g <- ggplot(battles) + geom_bar(aes(Location)) # Bar chart

# Change to relative paths and save the data
ggsave(filename = "/home/repl/survival/graphics/locations.pdf", plot = g)
Code bearbeiten und ausführen