Showing posts with label data. Show all posts
Showing posts with label data. Show all posts
Sunday, December 22, 2013
Content of this tutorial blog
Labels:
analyzing,
anaysis,
Basic,
blog,
content,
data,
home,
Introduction,
models,
Overview,
prediction,
R,
regression,
tutorial
2.4 Modifying data in R
Modifying data in R
The R console has a simple tool called Data Editor to review and modify an important data file.
The data editor
The data editor opens by clicking on Edit in the window of the R console: Edit-> Data Editor. The window appears that asks about which dataframe and matrix to open. Here you type in the name of the matrix and confirming this by clicking OK. Figure 18 shows that the variable/matrix Projects is typed in for review.
![]() |
Figure 18: Selecting a variable in the Data Editor of R |
After choosing a variable/matrix to modify, the data appears in the form of a spreadsheet. Here you can modify different cells. If you click at the top of the spreadsheet, the window Variable Editor appears. Here you can choose between to data types: Numeric (values of the variable should be interpreted as numbers) and Character (values of the variable should be interpreted as categories). Figure 19 shows that the variable Customer satisfaction (TevredenheidKlant) is interpreted as character. You can change this by selecting numeric.
![]() |
Figure 19: Variable editor of R, interpreting values of variables as numeric or character |
Saturday, December 21, 2013
1.3 Importing the data set in the R Console
Importing data in R
Verify if the correct Working Directory is set. Also make sure that the data files are placed in this folder.
If these two operations are executed, you are ready to import data files into the R console.
Importing the csv file
![]() |
Figure 6: Importing and making a matrix of the data file |
You can select the file you wat to import into the R console. This can be executed in the following way:
- Importing the data file: Type in the command read.csv('*name of your file*'). In the example of Figure 6 the file Flowersales.csv is imported. In this example the code read.csv('Flowersales.csv') is used. After pressing Enter information about the data set appears in the R console. Please note that the code that is inserted in the R console is case sensitive, "flowersales.csv" could not be found. Please also not that the name of the file has to be put between 'quotation marks'.
- Creating a variable for the data file: The next step is creating variables for the data file. In the introduction of this tutorial it is explained how to create a variable with the <- code. For the data file Flowersales.csv a variable is created. This is done by using the following code: Flowersales<-read.csv('Flowersales.csv'). The file Flowersales.csv is no longer seen as an external file, but as a variable in this session. This makes analyzing the data set in the R console way easier. The purpose of making a variable is that the code for importing the data file [read.csv('Bloemenverkoop.csv')] does not have to be insterted every time. Now that a variable is created for this data file, you only have to type in Flowersales to show information about the data file.
- Making a matrix of the data file: By making a matrix of the just created variable Flowersales, the R console could read the data in a better way. Making a matrix in the R console is easy by using the command: attach(*Name of the variable of the data file*). Figure 6 shows that the command attach(Bloemenverkoop) is used (Bloemenverkoop is the Dutch word for Flowersales). Now catagories of the data set could easy be shown in the R consol. For example by showing information about the catagory Tulips, you easily use the command Tulips. In the next chapter you will see that in front of the command Tulips differerent functions could be placed to analyze this catagory.
Remarks
- Like chapter 1.1 explains about the Working Directory; The Working Directory is a map in which R searches for data files. So, the data files you want to analyze have to be placed in this map to be found by R.
- It is not neccesary to name the variable Flowersales, you could decide yourself how you name the variable. With the <- code R recognized the data file. Flowers<-read.csv('Flowersales.csv') is for example acceptable as well. In this case the variable Flowers has to be used during the whole analyzing process in the R console.
To the next step: 1.4 The basic functions of R for analyzing data
Subscribe to:
Posts (Atom)