Introduction to RStudio



Similar documents
Using R for Windows and Macintosh

FIRST STEPS WITH SCILAB

JustClust User Manual

Step 2: Save the file as an Excel file for future editing, adding more data, changing data, to preserve any formulas you were using, etc.

Microsoft Word 2011: Create a Table of Contents

A Short Guide to R with RStudio

SPSS 12 Data Analysis Basics Linda E. Lucek, Ed.D

Importing Data into R

Getting Started with R and RStudio 1

Beginner s Matlab Tutorial

Address Collector. - Tutorial -

Introduction to SPSS 16.0

Creating a Network Graph with Gephi

Importing and Exporting With SPSS for Windows 17 TUT 117

KI6501 Data Manager. Software User Manual

UCINET Quick Start Guide

Data Mining. SPSS Clementine Clementine Overview. Spring 2010 Instructor: Dr. Masoud Yaghini. Clementine

Using the Local Document Organizer in ProjectWise

How To Use Spss

Market Pricing Override

Fireworks 3 Animation and Rollovers

INTRODUCTION TO DESKTOP PUBLISHING

Creating a Poster in Powerpoint

CREATING AN IMAGE FROM AUTOCAD CADD NOTE 16. MENU: AutoCAD, File, Plot COMMAND: plot ICON:

Using Big Datasets in Stata

William E Benjamin Jr, Owl Computer Consultancy, LLC

Using NHSN Analysis for Prevention Getting Started

OneNote. Introduction to OneNote Uses and Features. Launch OneNote User Interface Title Bar Quick Access Toolbar Ribbon

Export. Exporting Client Addresses

Tutorial 2: Reading and Manipulating Files Jason Pienaar and Tom Miller

Chapter 14: Links. Types of Links. 1 Chapter 14: Links

Generating ABI PRISM 7700 Standard Curve Plots in a Spreadsheet Program

Oracle BI Extended Edition (OBIEE) Tips and Techniques: Part 1

CDOT Linking Excel Documents to MicroStation

Monitoring Oracle Enterprise Performance Management System Release Deployments from Oracle Enterprise Manager 12c

DWGSee Professional User Guide

Chapter 12 Creating Web Pages

Adobe Acrobat 6.0 Professional

Finding Drag Coefficient using Solidworks Flow Simulation

Working with Excel in Origin

GelAnalyzer 2010 User s manual. Contents

Tutorial #7A: LC Segmentation with Ratings-based Conjoint Data

Universal Simple Control, USC-1

Generate Android App

Getting Started with Mplus Version 7.31 Demo for Mac OS X and Linux

Installing R and the psych package

Please follow these guidelines when preparing your answers:

Paperless Meeting Software Installation Instructions

SPSS Introduction. Yi Li

IBM SPSS Statistics 20 Part 4: Chi-Square and ANOVA

R Commander Tutorial

Exploratory Data Analysis and Plotting

Working with Office Applications and ProjectWise

Dealing with Data in Excel 2010

Quick and Easy Web Maps with Google Fusion Tables. SCO Technical Paper

Tutorial for Tracker and Supporting Software By David Chandler

InfiniteInsight 6.5 sp4

GUIDE TO REDCAP EXPORTED FILES

1 Topic. 2 Scilab. 2.1 What is Scilab?

SnagIt Add-Ins User Guide

LAB 1 Intro to Ucinet & Netdraw

Hands-on Exercise Using DataFerrett American Community Survey Public Use Microdata Sample (PUMS)

March Module 3 Processing MOVES Output

KFUPM. Web Content Management System powered by SharePoint

Maple Quick Start. Introduction. Talking to Maple. Using [ENTER] 3 (2.1)

GeoGebra Statistics and Probability

ACTIVE TRADING WITH TRADESTATION AND THE STOCKSCORES STRATEGIES

SPSS for Windows importing and exporting data

i and newer Consultant EyeSuite Tips & Tricks Connect to Holladay IOL

Dreamweaver Tutorials Creating a Web Contact Form

Applying a circular load. Immediate and consolidation settlement. Deformed contours. Query points and query lines. Graph query.

Google Apps for Sharing Folders and Collecting Assignments

Creating a Newsletter with Microsoft Word

Topography of an Origin Project and Workspace

PowerPoint 2013 Basics for Windows Training Objective

Gerrit Stols

Group Mail Lists. Group Mailing Lists. Populating a Global Mail Lists 4. The Problem 6. The Solution 8. Scheduling Regular Updates 17

How to Mail Merge PDF Documents

How to Create a Link

There are six different windows that can be opened when using SPSS. The following will give a description of each of them.

How to work with Sub Drawing

Lab 3: Introduction to Data Acquisition Cards

How to deploy fonts using Configuration Manager 2012 R2

Petrel TIPS&TRICKS from SCM

BD CellQuest Pro Software Analysis Tutorial

Manual. OIRE Escuela de Profesiones de la Salud. Power Point 2007

Modelling with R and MySQL. - Manual - Gesine Bökenkamp, Frauke Wiese, Clemens Wingenbach

4 Other useful features on the course web page. 5 Accessing SAS

Shopping Cart Setup & Configuration Guide

Chapter 12 Creating Web Pages

Chapter 12 Creating Web Pages

Time Series Analysis of Aviation Data

SPSS: Getting Started. For Windows

Introduction to R Statistical Software

This activity will guide you to create formulas and use some of the built-in math functions in EXCEL.

Transcription:

Introduction to RStudio (v 1.3) Oscar Torres-Reyna otorres@princeton.edu August 2013 http://dss.princeton.edu/training/

Introduction RStudio allows the user to run R in a more user-friendly environment. It is open-source (i.e. free) and available at http://www.rstudio.com/ For R related tutorials and/or resources see the following links: http://dss.princeton.edu/training/ http://libguides.princeton.edu/dss 2

RStudio screen The workspace tab shows all the active objects (see next slide). The history tab shows a list of commands used so far. The console is where you can type commands and see output The files tab shows all the files and folders in your default workspace as if you were on a PC/Mac window. The plots tab will show all your graphs. The packages tab will list a series of packages or add-ons needed to run certain processes. For additional info see the help tab 3

Workspace tab (1) The workspace tab stores any object, value, function or anything you create during your R session. In the example below, if you click on the dotted squares you can see the data on a screen to the left. Showing here matrix B. To see matrix A click on the respective tab. 4

Workspace tab (2) Here is another example on how the workspace looks like when more objects are added. Notice that the data frame house.pets is formed from different individual values or vectors. Click on the dotted square to look at the dataset in a spreadsheet form. 5

History tab The history tab keeps a record of all previous commands. It helps when testing and running processes. Here you can either save the whole list or you can select the commands you want and send them to an R script to keep track of your work. In this example, we select all and click on the To Source icon, a window on the left will open with the list of commands. Make sure to save the untitled1 file as an *.R script. 6

Changing the working directory 1 2 If you have different projects you can change the working directory for that session, see above. Or you can type: # Shows the working directory (wd) getwd() # Changes the wd setwd("c:/myfolder/data") More info see the following document: http://dss.princeton.edu/training/rstata.pdf 3 7

Setting a default working directory 1 2 3 Every time you open RStudio, it goes to a default directory. You can change the default to a folder where you have your datafiles so you do not have to do it every time. In the menu go to Tools->Options 4 8

R script (1) The usual Rstudio screen has four windows: 1. Console. 2. Workspace and history. 3. Files, plots, packages and help. 4. The R script(s) and data view. The R script is where you keep a record of your work. For Stata users this would be like the do-file, for SPSS users is like the syntax and for SAS users the SAS program. 9

R script (2) To create a new R script you can either go to File -> New -> R Script, or click on the icon with the + sign and select R Script, or simply press Ctrl+Shift+N. Make sure to save the script. Here you can type R commands and run them. Just leave the cursor anywhere on the line where the command is and press Ctrl-R or click on the Run icon above. Output will appear in the console below. 10

Packages tab The package tab shows the list of add-ons included in the installation of RStudio. If checked, the package is loaded into R, if not, any command related to that package won t work, you will need select it. You can also install other add-ons by clicking on the Install Packages icon. Another way to activate a package is by typing, for example, library(foreign). This will automatically check the --foreign package (it helps bring data from proprietary formats like Stata, SAS or SPSS). 11

Installing a package Before 1 3 2 We are going to install the package rgl (useful to plot 3D images). It does not come with the original R install. Click on Install Packages, write the name in the pop-up window and click on Install. After 12

Plots tab (1) The plots tab will display the graphs. The one shown here is created by the command on line 7 in the script above. See next slide to see what happens when you have more than one graph 13

Plots tab (2) Here there is a second graph (see line 11 above). If you want to see the first one, click on the left-arrow icon. 14

Plots tab (3) Graphs export To extract the graph, click on Export where you can save the file as an image (PNG, JPG, etc.) or as PDF, these options are useful when you only want to share the graph or use it in a LaTeX document. Probably, the easiest way to export a graph is by copying it to the clipboard and then paste it directly into your Word document. 2 1 3 Make sure to select Metafile 5 Paste it into your Word document 4 15

3D graphs 3D graphs will display on a separate screen (see line 15 above). You won t be able to save it, but after moving it around, once you find the angle you want, you can screenshot it and paste it to you Word document. 16