top of page
Assignment #2 using R:
 
Use the data file that you created in assignment #1. The data set should have the original variables with the names IV1, IV2 and DV, as well as the new variables that you created in assignment #1 (i.e. ID, R_IV1, R_IV2, TwoIVs and R_DV). If you made mistakes in assignment 1, you need to correct those mistakes before you work on assignment 2. If you do not correct the mistakes, you will not get the correct answers in assignment 2. Make sure that the script file creates all variables that are used in the assignment. This is very important because I will need to be able to run your R script file on my computer and get all the answers, without creating new variables or making any other edits to your script file. That will not work unless all variables have been created in the R script file and your data file is in the statlab folder in your C:/ drive.
 
Use either Excel or R to complete this assignment.​

Assignment #2 tasks. 

a) Create a box plot for the variable R_IV1. Give the box plot a main title that follows the naming convention, Last name's box plot. For example, my title would be Corwyn's box plot.  Label the x axis, "x axis" and name the y axis, "y axis".

​b) Create a stem-and-leaf plot for Two_IVs. You must complete all the set up for the stem and leaf shown in the video, including constructing the table for the stem and leaf. You must have 4 or more leaves in your plot. You must create all the stems and leaves for full credit, but you can earn half credit if you complete one set of leaves that represents values that appear in the data. ​

c) Create a frequency table for the variable R_IV2.  The frequency table should include the number of occurrences of every value in R_IV2 as well as the cumulative percent of every value, in ascending order.​​

d) Calculate the sum of all (X-Xbar)^2 values for R_IV1, where X = the R_IV1 values and Xbar is the mean of R_IV1. Remember that ^2 is a symbol for squared. So you will create a variable that has the values of X-Xbar and then you will create a variable that squares the X-Xbar values. Then you will sum all of the values in the last step (see videos).​

Upload your completed assignment to the submit assignment 2 page.

Send your R script file that produced your answers to a, b, c and d to rbflynn@ualr.edu and lxcarl@ualr.edu. In addition, copy the contents of your R script file and paste it into a Word document and submit that Word document through the Wix submission page for assignment #2. It is necessary to send your R script file to us because Wix will not accept R script files. 
 
I should be able to run all the code in your R script file and get all of your answers. If you are using R, there is no need to turn in your actual tables or plots because they will be produced when I run your R code in R Studio. Name your R script file as follows. Last name, First and middle initial (in caps), underscore and assignment2. For example, my name is Robert Flynn Corwyn so my file would be CorwynRF_assignment2.R. Notice that R script files have the .R extension.
 
You need to read your data from the statlab folder in the C drive of your computer (see correct code in green below). Please do not use R code that allows you to read a file that is already opened on your computer (see red code below). This is important because you want your program to run on another computer. 

classdataS20 <- read_excel("classdataS20.xlsx")

classdataS20 <- read_excel("C:/statlab/classdataS20.xlsx")

Mac users, please refer to the document here, and the video here on how to import and read data on a Mac. There is also important information about how to make sure your script will run on a Windows machine for this class.

Read the instructions carefully. Failing to follow instructions will cost you points. One point will be counted off for failing to follow directions, even if your assignment is otherwise flawless. If you fail to follow more than one instruction, you can be counted off 1 point for each violation. One point will be counted off for failing to tell us where you are answering questions a, b, c, d, etc., and failing to name your file correctly.

If you use R, one point will be counted off for failing to read data files from the statlab folder in the C drive and failing to send your .R script file to all instructors and tutors (see instructions for a list of individuals to send your R script file to).  

If you use R on a Mac, please enter the code that is needed to read your file on a PC and place # in front of that line (e.g. this is an example of the code we ask Mac uses to include (#classdataS20<-read_excel("C://statlab/classdataS20.xlsx"). If we cannot read your data on a PC, by deleting the # sign and running the line, one point will be taken off.

If you use R, please place a # sign in front of any line that installs a library (e.g. #install.packages("readxl")), views data (e.g. #view(classdata)), or updates packages (e.g. #update.packages( ). One point will be taken off for not doing this.If you use Excel, you will miss a question entirely if you do not use formulas in cells where calculations of any kind are made. Do not manually enter data in any cell that the video tells you to use a formula.

This assignment is worth 10 points. 
bottom of page