Tuesday, September 16, 2014

Set Working Directory & Get Working Directory - R Software - Basics Class

The practice sheet titled StatisticMarks Data.csv downloaded from Link. – Download Sheet

About the Data Sheet - The data in this sheet is related to marks scored by 100 Students in a Statistical Test. 

Based on the data, we will use R Software Statistical functions to analyze the descriptive statistics. 

In the Data Sheet, we have Data from A2:A101, A1 being the header of the Data. 

Best Practice in R Software, Set the Working Directory, so that we can directly import & export Data files in R.

If you want to read files from a specific location or write files to a specific location you will need to set working directory in R.

The below example guides users how to set the working directory in R to the folder “Data” within the folder “Documents and Settings” on the C drive.

# Set the Working Directory Command
setwd(“ ”)
setwd("C:/Documents and Settings/Data")
Always remember to use the forward slash / or double backslash \\ in R.
The Windows format of single backslash will not work.

If you need to access the working Directory,
getwd()
 # get current working directory

In our case, I have set working directory titled “R” on Desktop.

setwd("C:/Users/Rajesh Prabhakar/Desktop/R")

I have stored my data file titled “StatisticMarks.csv” in the “R” folder I created on Desktop and which I have set as my working Directory.

For inputting or reading Data from “StatisticMarks.csv” file, R Command would be
StatMarks=read.csv("StatisticMarks.csv")


I have named input variable name as StatMarks so that it will be easy for reading data into the statistical function formulas. 

No comments:

Post a Comment