Assignment #6 Hints – A Checklist
Dear R experts,
While working on Assignment #6, 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. 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 ICAs #9.1 and #9.2.)
2. Under the VARIABLES section, did you change the following variable values accordingly for the new dataset?
3. Were you able to install the “psych” package? (Does lines 30-31 work?)
If not, close RStudio, then open R (instead of RStudio), copy and paste lines 30-31 into the R Console, press enter, and see if the package is correctly installed. You may be asked to pick a mirror, just pick one in the US. Once you finish, re-open RStudio and re-run the code to see it works now.
4. 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:
(1) 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.
(2) Make sure that you changed line 87:
subset <- dataSet[ which(dataSet$Position=='PG' | dataSet$Position=='SF'), ];
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).
If you have everything listed above checked, you should be able to at least complete the first six steps on the assignment.
5. 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
You must be logged in to post a comment.