AllFreePapers.com - All Free Papers and Essays for All Students
Search

Data Mining Lab

Autor:   •  February 3, 2017  •  Coursework  •  1,368 Words (6 Pages)  •  996 Views

Page 1 of 6

Goals

MIS 510 Lab 1: APIs

January 31, 2017

• Learn how to use R Studio and some basic R syntax

• Learn to use APIs to get social media data

Deliverables

• 1. Using the Twitter API: get a list of trending topics in Tucson

• 2. Using the LinkedIn API: get your basic profile information

Preparation

Create an R Working Directory

A working directory is a directory where you can store all the data and code files for a programming project. Create or choose a working directory on your computer for this course.

Then, we need to tell R where to find it. Open R Studio. Go to Session > Choose Working Directory > Set Working Directory, and set the Working Directory for this project.

Using files

Go to File> New File > R Script. This opens up a new file, in which you can store long snippets of code. In your blank file in, type in the following. ( # makes this line a comment).

# MIS 510 Lab 1

To save a file, go to File > Save.

R Studio will automatically prompt you to save the file in your working directory. Save the file and close the tab with the file.

Now, try opening it: Got the File > Open. You should be able to see the file you just saved because we are still in the Working Directory.

Basic R Syntax

Installing Packages

Most of the time when you in R, you will need to use libraries. There are several R libraries you will need to install for this lab. To install packages, use the R command install.packages('package-name'). After installation, you will need to load the packages. For this lab, we will need to install and load the following packages:

You may also want to cache authentications to make execution faster. This is optional.

Assign value

Now let’s cover some basic R syntax. To assign values, you can use either ‘=’ or ‘<-’.

R uses vectors for many operations. You can create vectors with the c(...) function: Show/print values

When we print this, it is a two dimensional vector:

Paste

To concatenate elements of a vector, use paste. We can also use this to concatenate two

...

Download as:   txt (8.8 Kb)   pdf (55.2 Kb)   docx (12.5 Kb)  
Continue for 5 more pages »