Ensure that you have R and RStudio installed in your PC. For installation instructions go to:
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
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