4Data Input and Dataframes

In this chapter, we will explore how to import data into images and then, when it has arrived, how to manipulate its default structure, known as a dataframe. Obviously, data can be typed directly into images using c () and other functions, but we will assume from now on that the data is held in a file, usually a spreadsheet.

4.1 Working directory

images always has a working directory which is where it will attempt to read and write files. It's easy to find the current working directory:

c04g3001

The simplest way to organise things is to set the working directory to wherever (directory or folder) the project we are working on is based, as soon as images is started. Presumably, any data files we import will already be located there and then when we save a program, plot, data file, etc., it will automatically be saved to the same place. There are a number of ways to do this. Let us assume that the directory is C:/project. Then we could type:

Alternatively, in RStudio, we can click on ...

Get The R Book, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.