Chapter 3 Loading data
This chapter explains how to load data. For each statistical package, it has two sections. The first section is about the general case: loading data from a file. The second section is about loading one of the example datasets that accompany this book.
The first steps to open a dataset are the same, regardless of whether you want to open a Rosetta Stats example dataset or a different file. First, open the main jamovi menu by clicking the hamburger menu in the top-left corner, just left of the text “Data” (see Figure 3.1.
This will open the menu shown in Figure 3.2. In that menu, click the text “Open”. This will expand two options in this menu: “This PC” and “Data Library”. Which you choose depends on whether you want to open a file from your PC, or whether you want to open a Rosetta Stats example dataset.
3.1.1 Loading data from a file
To open a file on your PC, click “This PC” in jamovi’s “Open” menu.
3.1.2 Loading a Rosetta Stats example dataset
To open a Rosetta Stats example dataset, click “Data Library” in jamovi’s “Open” menu (see Figure 3.2). By default, the jamovi data library already comes with a number of datasets, but installed modules can add more datasets.
If you installed the “rosetta” jamovi module, you should see the corresponding folder in jamovi’s data library (see Figure /(???)(fig:software-basics-jamovi-opened-data-library)). If you do not see this folder, install the “rosetta” module as explained in section 2.2.1.
Open the Rosetta data library by clicking the corresponding folder. This will show the Rosetta Stats example datasets, as shown in Figure ??. Click the dataset you wish to open, and jamovi will open it.
rosetta package has a function called
getData() that will open a dialog where you can select your datafile. You have to specify under what name to store the data frame using an arrow:
There is a convenience function called
getDat() that doesn’t require you to specify the name, but always stores it as
If you use RStudio, there is a very simple way to load data: you can use the “Import Dataset” menu from the top right menu in RStudio. (see Figure 3.5). From there, select the type of data you want to import and follow the point and click menus.
The dataset will import into R with the name of the saved file. This can be relatively long and so tedious to keep typing, so it is common to rename these datasets to a shorter name, such as “dat”. To do this, you can copy the dataset to another name with the arrow.
To confirm the dataset was renamed correctly, you can view the variables stored in it:
You can also view the data in a spreadsheet format. If you use RStudio, it will appear as a new tab next to your R script. You can toggle back and forth between the two.
3.2.3 Loading a Rosetta Stats example dataset
To see a list of the Rosetta Stats example datasets, use the command
data, specifying the package name as named argument
To load one of the datasets, assign it to a name of your choice, specifying both the package name and the dataset name, separated by two colons. In the examples in this book, we will always use
dat as the name. For example, to load the dataset
Note that to use variables from the dataset, you don’t have to store it locally; you can directly specify variables in analyses using
rosetta::pp15 as dataframe name (a “dataframe” is the name for a loaded dataset in R).
3.3.1 Loading an SPSS dataset
To open an SPSS dataset in SPSS, select “File”, “Open”, “Data” from the menu bar (see Figure 3.6). Navigate to the dataset you wish to open and select it.
3.3.2 Importing a non-SPSS dataset
To import a different type of dataset into SPSS, select “File”, “Import Data” from the menu bar and select the data type (see Figure 3.7). Navigate through the menu options for the data type to open the dataset.
3.3.3 Loading a Rosetta Stats example dataset
The pp15 dataset is saved as a text file. To import a text file into SPSS, select “File”, “Import Data”, “Text Data” (see Figure 3.7). Navigate to the pp15 dataset, select it, and click “Open” (see Figure 3.8).
There are 6 steps to click through to load the dataset. We do not have a predefined format for out text file, so we will press “Next” on Step 1 without modifying anything. At Step 2, there are several things to check. Look at the snapshot of the data at the bottom of (Figure 3.9) in the black box and note that the data are delimited by a semi-colon. Therefore, we will select “Delimited” under “How are your variables arranged?” (1). Also note in the data snapshot that there are variable names at the top of the file. Therefore, will select “Yes” under “Are variable names included at the top of your file?” (2). Finally, note that this dataset comes from the Netherlands, where it is common to use a comma as a decimal. Thus, we will select “Comma” under “What is the decimal symbol?” (3).
We do not need to change any of the defaults in Step 3 and can just press “Next”. We saw in the data snapshot at the bottom of Figure 3.9 that the data were delimited by a semicolon, so we will make sure to only select “Semicolon” under “Which delimiters appear between variables?” in Step 4. There is nothing to modify in Step 5 or 6, so we can simply press “Next” and “Finish”. The pp15 dataset will now load in SPSS.