🗓️ Session 5a: Recap session

Published

23 10 2026

Modified

23 10 2026

This on-site session was a pure recap session: no new material was introduced. Instead, we discussed the topics from the previous sessions that you wanted to go through again. We focused on two of them: how to tell R where your files are (absolute vs. relative paths and the here package), and the different object types in R and how they relate to each other.

The new material of this week, Quarto and R Markdown, is covered in the videos of session 5.

📂 Absolute and relative paths, and the here package

We discussed the difference between absolute paths (starting at the root of one specific computer) and relative paths (starting at the current working directory), and why only paths built with the here package keep working when your code moves to another computer, another folder, or another working directory.

We went through parts of a small hands-on exercise. The repository contains three scripts that read the same data file with an absolute path, a hard-coded relative path, and here, respectively. Download it as a ZIP file and work through the experiments described in its README:

Go to the exercise repository

The background is covered in Part III of the slides on project management from session 3, and in the following reading:

🧱 Object types and their hierarchy

We then discussed the most important object types in R and how they build on each other. Here is the script we used in the session, but very much expanded to give you more details and examples:

The table summarises section 8 of ObjectHierarchy.R. Read it row by row: to transform an object of the type in the first column into the type in the header, use the function in the cell.

* gives the internal codes, not the labels; use as.numeric(as.character(x)) to get the values.
from ↓ \ to → logical integer double character list factor data.frame
logical — as.integer() as.double() as.character() as.list() factor() —
integer as.logical() — as.double() as.character() as.list() factor() —
double as.logical() as.integer() — as.character() as.list() factor() —
character as.logical() as.integer() as.double() — as.list() factor() —
list unlist() unlist() unlist() unlist() — — as.data.frame()
factor — as.integer()* — as.character() as.list() — —
data.frame — — — — as.list() — —
  • Upwards in the atomic hierarchy (logical → integer → double → character) nothing gets lost.
  • Downwards, values can be truncated (as.integer(2.99) is 2) or become NA (as.numeric("two")).
  • Always check the result with typeof() or class() after transforming an object.

The checklist at the end of ObjectTypesInPractice.R; go through it every time you work with a new data set.

The slides, videos and exercises are on the page of session 4. The relevant readings are:

✍️ Coursework

  • Finish the experiments in the here-paths-demo repository
  • If you have not done so yet, do the ObjectTypes1 and ObjectTypes2 exercises of the package DataScienceExercises (see session 4)
  • If you have questions or problems, please post them in the Moodle forum

References

Gräbner-Radkowitsch, C. (2026a) “Object Types in R I: Functions” C. Gräbner-Radkowitsch (ed.), Method and Inquiry, available at https://euf-methodology-hub.netlify.app/resources/r-object-types-i-functions.
Gräbner-Radkowitsch, C. (2026b) “Object Types in R II: Vectors” C. Gräbner-Radkowitsch (ed.), Method and Inquiry, available at https://euf-methodology-hub.netlify.app/resources/r-object-types-ii-vectors.
Gräbner-Radkowitsch, C. (2026c) “Object Types in R III: Factors and Data Frames” C. Gräbner-Radkowitsch (ed.), Method and Inquiry, available at https://euf-methodology-hub.netlify.app/resources/r-object-types-iii-factors-dataframes.
Gräbner-Radkowitsch, C. (2026d) “Setting Up an R Project” C. Gräbner-Radkowitsch (ed.), Method and Inquiry, available at https://euf-methodology-hub.netlify.app/resources/setting-up-an-r-project.