Instructor: Jing Gong. Class Time: M/W/F 2:00-2:50 pm

Assignment #5 Hints – A Checklist

Dear R experts,

While working on Assignment #5, you may experience errors. In order to at least run the script without error messages, you often have to “debug” to fix the errors.

Here is a list of things you can check:

1. Error Message. If you get an error message like this:

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'OnTimeAirport-Jan14.csv': No such file or directory

ask yourself the following questions:

  • Did you have all the files (both Descriptives.r file and OnTimeAirport-Jan14.csv file) in the same directory/folder?
  • Are the file names correct? Sometimes when you download the file to your disk multiple times, the system automatically rename the files (like OnTimeAirport-Jan14(1).csv). If this is the case, you have to change the name back.
  • Did you set the working directory to source file location? (How to do that? Read instructions on ICA #9)

2. Changing Variable Values. Under the VARIABLES section, did you change the following variable values accordingly for the new dataset?

  • INPUT_FILENAME
  • HISTLABEL
  • HIST_TITLE

3. Package Installation. Were you able to install the “psych” package?
If not, check the solutions here: Problems Installing Packages?

4. Modifying R Script. In the original Descriptives.r file, our analysis was based on the NBA data. Specifically, we looked at two columns, dataSet$Salary and dataSet$Position. For the assignment, because we are using a different dataset called OnTimeAirport-Jan14.csv, you need to make the following changes accordingly:

  • Do a thorough search of your r script and make sure that you changed all places with dataSet$Salary and dataSet$Position to the new columns we are interested in in the new dataset.
  • Make sure that you changed line 87:
subset <- dataSet[ which(dataSet$Position=='PG' |  dataSet$Position=='SF'), ];

into:

subset <- dataSet[ which(dataSet$Origin=='PHL' |  dataSet$Originn=='PIT'), ];

The reason is that now we are interested in looking at Philadelphia and Pittsburgh as origin airports (as asked in Question 5 of the answer sheet).

  • Make sure that “dataSet” has the right cases (i.e., the letter “S” should be in upper case). This is because R is case-sensitive.

If you have everything listed above checked, you should be able to at least complete the first six steps on the assignment.

5. Adding More Commands. To complete Steps 7-9, you should add a few more lines in between the t.test() and the sink() functions. More specifically, I recommend you to add lines right before the following line (line 95 of the original Descriptives.r file).

# This stops R from writing any more to the text output file.

That’s all I can think of so far. Good luck!

Leave a Reply