Chapter 8 Objects, working directory and workspace

  • Possible storages
    • Harddrive
    • “Workspace”: Storage within R
    • Online on some server
    • Q: Who has his own server?
  • Working directory
    • getwd(): Display working directory
    • setwd(): Set working directory
    • dir(): Display files in working directory
    • R does not understand \
      • Use \\ instead or / in directory paths
    • #: Start comment that is not evaluated


  • Objects
    • Meaningful names; No blanks
    • a <- 10 or a = 10: Assign something to an object
    • a: Type name to display content of object a
    • rm(): Delete object from workspace
    • save(a, b, file = "myobjects.RData"): Save single objects a and b
    • load("myobjects.RData"): Load saved objects


  • “Workspace”
    • …stores all objects generated during the session
    • …is loaded automatically when you start R
    • ls(): Display workspace content
    • R queries whether you would like to save the workspace when quitting it