Difference between revisions of "R/C2/Working-directories-in-RStudio/English"
Sudhakarst (Talk | contribs) |
Sudhakarst (Talk | contribs) |
||
Line 79: | Line 79: | ||
| We will find out what our current '''Working Directory''' is. | | We will find out what our current '''Working Directory''' is. | ||
− | + | Let us switch to '''RStudio'''. | |
|- | |- | ||
| [RStudio] | | [RStudio] |
Revision as of 13:20, 17 January 2019
Title of script: Working directories in RStudio
Authors: Shaik Sameer (IIIT Vadodara) and Sudhakar Kumar (IIT Bombay)
Keywords: R, RStudio, working directory, read csv
<center>Narration | |
Show slide
Opening slide |
Welcome to this tutorial on Working directories in RStudio. |
Show slide
Objectives |
In this tutorial, you will learn about:
|
Show slide
Pre-requisites |
To understand this tutorial, you should know:
If not, please locate the relevant tutorials on R on this website. |
Show slide
Systems requirements |
This tutorial is recorded on
Install R version 3.2.0 or higher. |
Text on screen
Download CaptaincyData.csv file from the Code files link |
We will use the captaincy data set which we created earlier in this series.
Download this data set CaptaincyData.csv from the Code files link of this tutorial. |
[Computer screen]
Highlight CaptaincyData.csv in the folder myProject |
I have downloaded and moved this data set to the folder myProject on my Desktop.
I shall set this folder as my Working Directory. |
Show slide
R scripts |
|
Show slide
Working directory |
|
We will find out what our current Working Directory is.
Let us switch to RStudio. | |
[RStudio]
Console >> type getwd() |
In the Console window, type getwd parentheses and press Enter. |
Point to /home/fossee in Console | The current Working Directory is shown in the Console.
Note down the directory path. |
Now, we will learn how to set our Working Directory. | |
[RStudio]
Highlight myProject folder on Desktop |
I will set the folder myProject on my Desktop as my Working Directory. |
I am maximizing the Files and Plots window of RStudio. | |
Go to graphical output window at the bottom right >> select the Files tab | At the top of the Files and Plots window, click on the Files tab. |
Click on the button with three dots at the right corner | Go to the upper right corner of the same window.
Below the refresh icon, click on the button with three dots. |
Point to Go To Folder | Go To Folder window appears. |
Select myProject folder >> click Open | Select the folder which you want to make as your Working Directory and click Open.
I am selecting myProject located on my Desktop. |
Point to the two scripts under Files tab | Under Files tab, you can see that the two scripts created earlier, have been loaded. |
[RStudio]
Select More >> Set As Working Directory |
Now, below the Files tab, click on the More button with the blue gear symbol.
From the dropdown menu, select the Set As Working Directory option. Now this folder is set as your Working Directory. |
Point to the Console | You may verify this by looking at the Console. |
Now, I am minimizing the Files and Plots window. | |
There is one other way to set the Working Directory also. | |
[RStudio]
Console >> type setwd("/home/fossee/ Desktop/myProject") |
In the Console, type setwd.
Now, inside parentheses, type the desired folder path within double quotes. Press Enter. |
Highlight CaptaincyData.csv in the File tab | Now, we will learn how to read and store a csv file called CaptaincyData.csv. |
We shall declare a variable captaincy to store CaptaincyData.csv. | |
[RStudio]
captaincy = read.csv("CaptaincyData.csv") |
In the Console window, type captaincy space equal sign space read.csv
Now, CaptaincyData.csv inside double quotes in parentheses and press Enter. |
Highlight read.csv | read.csv function is used to read a file and to create a data-frame from it. |
[RStudio]
View(captaincy) Highlight the data frame in Source window |
Now, we use View function to see the stored data frame.
In Console window, type View captaincy in parentheses and press Enter. The contents of captaincy data frame appears in the Source window. |
This brings us to the end of this tutorial. Let us summarize. | |
Show slide
Summary |
In this tutorial, we have learned
|
Show slide
Assignment |
We now suggest an assignment.
|
Show slide
About the Spoken Tutorial Project |
The video at the following link summarises the Spoken Tutorial project.
Please download and watch it. |
Show slide
Spoken Tutorial Workshops |
We conduct workshops using Spoken Tutorials and give certificates.
Please contact us. |
Show Slide
Forum to answer questions |
Pls post your timed queries in this forum. |
Show Slide
Forum to answer questions |
Pls post your general queries in this forum. |
Show Slide
Textbook Companion |
The FOSSEE team coordinates coding of solved examples of popular books.
We give honorarium and certificates to those who do this. For more details, please visit these sites. |
Show Slide
Acknowledgement |
The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India |
Show Slide
Thank You |
This script for this tutorial was contributed by Shaik Sameer (FOSSEE Fellow 2018).
This is Sudhakar Kumar from IIT Bombay signing off. Thanks for watching. |