Assignment 1


Ensure that you have R and RStudio installed in your PC. For installation instructions go to:

Click here to download R

Click here to download RStudio

Once you have successfully installed R and RStudio, create a folder in a place that is easily accessible and call it r_working_directory. Then go to the desktop and right click on the R icon. Select properties. In the “Start In:” text box put the location of your r_working_directory folder

(e.g. C:\Users\Kevin\Documents\r_working_directory)

Be sure to read the R tutorial. Download R manual. Remember that R has an inbuilt help function that is accessible within the console by either typing ? followed by whatever it is you want to know more about or help( ) function. To test this out, type ?help in the R console.

To start us off, we will work with a simple data set. Sign up here to receive the dataset. Put your extracted data into your r_working_directory. Open RStudio and import the first dataset (testdata.txt) and list all the variable names (column names) then import the second dataset and do the same thing. Getting problems? Try the help function and see where you are going wrong. Try opening the dataset in notepad and look at the data. Then try and open each of them in excel (Hint: you have to import the txt file into excel).

Some of the code can be used as below.

The R Code

#First we get our data

mydata <- read.table(“testdata.txt”)


# Help with the function read.table(). Will also list all the arguments associated with the function

#mydata <- read.csv(“testdata.csv”, sep=”,”, header=TRUE)

# sometimes your data is in csv format and you want to tell R as much

names(mydata) #lists all the variable names


Submit the following:

  • the output after the names(mydata) function
  • Your excel sheet after importing the data indicating the scale of measurement for each variable

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s