Instructor: Jing Gong


Additional Topics: Accessing MySQL from R & Linear Regression

Here are some materials for two additional topics. These are optional and will not be covered in the third exam.

1. Accessing MySQL from R. The MySQL-Example.r script demonstrates how to query the moviedb schema on our class server using R. It will work with your MySQL account. With this nice tool you can extract data directly from a database by using SQL-statements, so that data can be analyzed in R.

2. Linear Regression is a statistical method to analyze the relationship between an continuous outcome variable and one or more predictor variables.

( Association Rules) Fix for Issue Related to Installing the Packages

If you get errors installing packages when running the aRules.r script, try the following:

1. Change lines 29~33 into the following. The original script uses CMU site ( as the repository to download the packages. But the CMU site seems to be broken today. The new lines use default R package repository, which seems to work today.

if (!require(“arules”)) { install.packages(“arules”)
require(“arules”) };

if (!require(“arulesViz”)) { install.packages(“arulesViz”)
require(“arulesViz”) };

2. If step 1 does not work, try to set the repository to a different one by following the instructions below:

1) In RStudio, go to Tools/Global Options…

2) Click on Packages (on the left).

3) Click on Change… under CRAN Mirror.

4) Choose one of the USA sites at the end (e.g., try the one in Dallas, TX).

5) Rerun the script. It should work. If not, try a different USA site.

If it doesn’t, let me know!


(Assignment 8) Error Installing the caret Package and Deadline Postponed

If you had problems downloading the “caret” package when running the script dTree.r, try a different computer.

Unfortunately, the computers in the Tech Center do not have R/RStudio installed. However the computer labs at Fox do have R/RStudio and seem to have no issue with the caret package (Thanks to Ashton Andrews for pointing this out). Here is the list of computer labs and hours within Fox:

Since the problem is a computer related issue and I am not sure if the labs are open on Sunday, I am going to move the deadline for the Decision Tree assignment to Wednesday, November 18 at 11:59 pm. It was originally due on Monday, November 16. If you have already submitted the assignment, there is no need to resubmit it.

Agenda for Wednesday and Friday

Hi all,

Here are some reminders:

– The Data visualization project ( aka Assignment #6) is due on Wednesday (10/28) before class.

– Wednesday will be exam review day.

– I will hold office hour on Wednesday at 2-3 pm and Thursday at 12-1 pm.

– Exam 2 is scheduled for Friday 10/30.

– Professor David Schuff will give a R/RStudio tutorial session on Wednesday 10/28 at noon in Alter 607. This event is hosted by AIS. If you are interested in knowing more about R/RStudio beyond class, I strongly encourage you to attend.

See you tomorrow in class.


Instructions to Set up R and RStudio

We will use R and RStudio for the second half of the course – to learn various analytical approaches. R is a widely-used, open source statistical analysis platform. RStudio is an integrated development environment for R – that means it makes using R easier.

Here are the instructions on how to set up R and RStudio on your computer: Setting up R and RStudio. Make sure you have both R and RStudio installed before October 21.

Videos/Files Uploaded for Data Visualization Exercise

Dear students,

Videos and files have been uploaded to the course website to make up for today’s class (available under “In-Class Exercises“). There are two exercises, Exercise #7.1 for creating maps using Google Sheets, and Exercise #7.2 for creating infographics using Piktochart. Please watch the videos and go through the exercises by yourself.

Stay safe.



***Important Changes*** Exam 1 Postponed to Wednesday

Dear students,

I feel compelled to postpone Exam 1 to Wednesday due to the threat of violence against “a university in Philadelphia.”

As you may know, Temple Police sent out a warning earlier that “Temple University, along with other colleges and universities in our region, has learned from the ATF (Bureau of Alcohol, Tobacco, Firearms and Explosives) that a threat of violence has been made online against ‘a university near Philadelphia.’ This posting states an action could take place at 1 p.m. central (2 p.m. eastern) Monday, Oct. 5, 2015.”

Considering the recent events in Oregon, I do not feel comfortable asking you to come to campus on Monday.

Therefore, I am making the following adjustments to the course schedule.

  • Monday 10/5  –  Class/Office hour cancelled. Exam 1 will be moved to Wednesday 10/7. We will not meet in class. I will upload materials and videos on Data Visualization that were originally scheduled for Wednesday.
  • Wednesday 10/7 – Students will take Exam 1 during class time. Do not forget that Assignment #3 (SQL-In) is also due in class on Wednesday 10/7.

I will hold extra office hours on Tuesday 10/6 between 11:30 and 1:00 pm. For Wednesday, I will move the office hours to 11:30 – 1:00 pm so more students can come.

Thank you for your understanding. Please let me know if you have any questions or concerns.

Jing Gong

Exam 1 Reminder

  • Date/Time: Monday, October 5, 3:00 – 3:50 pm
  • Place: Regular classroom (Alter Hall 232)

Please arrive 5 minutes early!

Remember to bring Black number 2 lead pencil and eraser. We will use blue exam answer sheet for multiple choice questions.


Best luck with your exam!