The Editor is your workspace and where the code you are working on is staying when you save your project. It is your place of input. The Console is giving you results of executions you request, the output. Usually, you execute code from the Editor by choosing one or several lines and press Ctrl + Enter or Cmd + Enter. The result will appear in the console. You can also directly type code in the Console and just hit Enter. Just be aware that once you close the program this code exclusively written out in the Console will be gone.
Besides that, there is by default on the right-hand side two more windows. On top you will find different ways to manage your data. The bottom panel has several tabs of which ‘Help’ can be of interest as a beginner. We will explore their features further in the next sessions.
You are able to collapse the separate the windows. If you accidentally altered the view and missing one you can find in the top bar ‘View’ > ‘Panes’ > ‘Show All Panes’.
Personal recommendation: If you like to personalize your R Studio as it makes working with it sometimes way more fun, go to the top choose ‘Edit’ > ‘Settings’ > ‘Appearance’ and choose a theme that excites you.
We recommend to create an RStudio project for all the work you do for
this module. This helps you keep your data and scripts (.R
-
or .Rmd
-files) organised.
In order to set up a new project in Rstudio:
.R
- or .Rmd
-files and saved in your “scripts”
folderIf you close and reopen RStudio, the last project should be reloaded automatically. If not the case, just navigate to the tab “File” and select “Open Project”.
Over the next sessions you will learn first-hand how important data management is. As we will work with raster data and also create our own, it is important to keep them sorted in one place. This is made easy by setting the folder in which your newly created data will be stored as your working directory.
For Windows remember that R uses forward slash (/) instead of the usually present backward slash () in Windows path names.
Example for Windows: setwd(“C:/User/Desktop/Fernerkundung/Seminar/Session1”)
Example for Mac: setwd(“/Users/Julia /Desktop /Fernerkundung/Seminar/Session1“)
Tipp for convenience: Windows: To copy the full path of a file or folder, hold Shift and right-click the file or folder, then select “Copy as Path” from the context menu Mac: When browsing the Finder in the bottom bar of the window you can “Copy as Pathname” instead of having to type it out.
If we want to save for example a newly created raster image, we can type out the following and it will automatically be saved in the folder we set as our working directory previously.
writeRaster(name, “chosen_filename.tif”, overwrite=T)
Copyright © 2023 Humboldt-Universität zu Berlin. Department of Geography.