Introduction to R. base -> R win32.exe (this will change depending on the latest version)

Similar documents
Instruction: Download and Install R and RStudio

Regression III: Advanced Methods

How to Download and Install R The R software can be downloaded from: Click on download R link.

Module 1: Introduction RStudio

Stat 302 Statistical Software and Its Applications Data Import and Export

A whirlwind introduction to using R for your research

Computer lab 2 Course: Introduction to R for Biologists

An Introduction to R 1.3 Some important practical matters when working with R

IN-CLASS EXERCISE: INTRODUCTION TO R

Installing and running R

Step by step to getting R installed on your computer

.txt - Exporting and Importing. Table of Contents

Introduction to R. 1 Introduction 2. 2 What You Need 2

QPM Lab 1: Installing R and R Studio

University of Wollongong School of Mathematics and Applied Statistics. STAT231 Probability and Random Variables Introductory Laboratory

Introduction to R Commander

Reading data into R. 1. Data in human readable form, which can be inspected with a text editor.

A system for statistical analysis. Instructions for installing software. R, R-studio and the R-commander

8.1 Come analizzare i dati: R

Programming R. Manuel J. A. Eugster. Chapter 1: Basic Vocabulary. Last modification on April 11, 2012

Introduction to Statistics using R/Rstudio

Switching to Sheets from Microsoft Excel Learning Center gsuite.google.com/learning-center

Exploring the Microsoft Access User Interface and Exploring Navicat and Sequel Pro, and refer to chapter 5 of The Data Journalist.

Lecture 1: Getting Started and Data Basics

R Website R Installation and Folder R Packages R Documentation R Search R Workspace Interface R Common and Important Basic Commands

my.scouting Tools Member Assignment Roster Details

Goals of this course. Crash Course in R. Getting Started with R. What is R? What is R? Getting you setup to use R under Windows

Introduction to R & R Commander

Lab 1. Introduction to R & SAS. R is free, open-source software. Get it here:

Code::Blocks Student Manual

Introduction to R. Dataset Basics. March 2018

CITO2 Installation & User Instructions

An Introduction to R- Programming

Instructions for using pre-defined EMIS Web searches with CHART

The R and R-commander software

Figure 1: The PMG GUI on startup

Desktop & Laptop Edition

Using Turnitin for electronic submission and marking of assignments: guidance paper for staff.

Version 1.6. UDW+ Quick Start Guide to Functionality. Program Services Office & Decision Support Group

RKWard: IRT analyses and person scoring with ltm

Introduction to RStudio

EMCO Remote Installer Professional 5. Copyright EMCO. All rights reserved.

STATA 13 INTRODUCTION

POL 345: Quantitative Analysis and Politics

Chapter 1 Introduction to using R with Mind on Statistics

Introduction to VA Analysis using openva the R Shiny App in Windows 10

The MAXQDA Stats Data Editor

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

Tutorial: SeqAPass Boxplot Generator

Process Eye Professional. Recall

User Guide DYMO Label TM v.8

HMIS Guide to Running & Retrieving the CSV APR 2017 Export in ClientTrack An HMIS End User Training Resource

Getting Started Guide

HOW TO BUILD YOUR FIRST ROBOT

edofe Management Toolkit

Updating Users. Updating Users CHAPTER

Introduction to R. Andy Grogan-Kaylor October 22, Contents

Lab 1: Getting started with R and RStudio Questions? or

DHL MyBill FAQ MyBill.dhl.com

An Introduction to R 1.1 Getting started

Below is an example workflow of file inventorying at the American Geographical Society Library at UWM Libraries.

Report Fundamentals An introduction to basic report functionality in SAP.

Testwise User Guide. Getting Started. UK gl-assessment.co.uk/testwise

> z <- cart(sc.cele~k.sc.cele+veg2+elev+slope+aspect+sun+heat, data=envspk)

R Basics / Course Business

Depending on the computer you find yourself in front of, here s what you ll need to do to open SPSS.

Note: For more information on creating labels in CDS, watch Volume 22 of the Fast Class Update: Label Creation.

Merging, exploring, and batch processing data from the Human Fertility Database and Human Mortality Database

Table of Contents. Part I How do I... Part II Zetafax Client. Foreword. 3 Advanced tasks. 1 Menu options. Annotate a fax? View a text message?

Introduction to R. UCLA Statistical Consulting Center R Bootcamp. Irina Kukuyeva September 20, 2010

BGGN 213 Working with R packages Barry Grant

MicroStrategy Desktop

MBV4410/9410 Fall Bioinformatics for Molecular Biology. Introduction to R

PART I (Must be done first) Download and Install R

Login: Quick Guide for Qualtrics May 2018 Training:

Guide to getting information out of Sage 200

Imagine. Create. Discover. User Manual. TopLine Results Corporation

Intellicus Enterprise Reporting and BI Platform

ACA-1095 Reporting Help Pro-Ware, LLC

Highway Performance Monitoring System

Job Aid. Remote Access BAIRS Printing and Saving a Report. Table of Contents

Chapter 11 Dealing With Data SPSS Tutorial

Flowlogic. User Manual Version GraphLogic: Developed by scientists, for scientists. Graphing and Statistical Analysis.

AG01 Run Quick Guide V1.0

Handling Your Data in SPSS. Columns, and Labels, and Values... Oh My! The Structure of SPSS. You should think about SPSS as having three major parts.

Chapter 10 Linking Calc Data

Working with Target for ArcGIS Drillhole Tools

CCRS Quick Start Guide for Program Administrators. September Bank Handlowy w Warszawie S.A.

Creating consistent content pages

To complete the computer assignments, you ll use the EViews software installed on the lab PCs in WMC 2502 and WMC 2506.

INSTITUTE BUSINESS SYSTEMS IMSS COGNOS REPORT STUDIO GUIDE

Adding Users. Adding Users CHAPTER

ForeScout CounterACT. Configuration Guide. Version 5.0

Specification Manager

Mintel Oxygen. User s Guide

CounterACT Reports Plugin

Before data can be exported out of CDS, an export definition must be created in the Import/Export utility.

WHI Virtual Data Enclave (VDE) User Guide

Outline. Mixed models in R using the lme4 package Part 1: Introduction to R. Following the operations on the slides

User Manual of ClimMob Software for Crowdsourcing Climate-Smart Agriculture (Version 1.0) Jacob van Etten

Transcription:

Dr Raffaella Calabrese, Essex Business School 1. GETTING STARTED Introduction to R R is a powerful environment for statistical computing which runs on several platforms. R is available free of charge. R is now under active development by a group of statisticians called 'the R core team', with a home page at www.r-project.org. The current version is 3.1.2 and was released in October 2014. New releases occur every six months or so, often around April and October. You will find binaries for Windows, Mac OS X and Linux in the Comprehensive R Archive Network. R users can program their own code. Hence, R is useful if you need to implement a new statistical method that is not available in SPSS or Excel. R is interactive to the user thus providing immediate feedback. It is highly versatile and ideal for statistical simulations such as monte carlo, jackknifing and bootstrapping. Finally, R source code is available for both inspection and modification where need be. Furthermore only a few tasks can be accomplished through the menu system and therefore it requires some effort to learn to use R. 1.1 R installation The first step to install R is to go to the site called Comprehensive R Archive Network (CRAN). It is a collection of sites which carry identical material, consisting of the R distribution(s), the contributed extensions, documentation for R, and binaries. Type its full address, http://cran.r-project.org/ or just type CRAN into Google and you will be taken to the site. Select under CRAN CRAN - Mirrors -> UK (http://star-www.st-andrews.ac.uk/cran/) Under Download and Install R click Windows and then base -> R-3.1.2-win32.exe (this will change depending on the latest version) Find the mirror (http://cran.r-project.org/mirrors.html) nearest you and follow the links. The Windows installer is fairly easy to use and, after agreeing to the license terms, lets you choose which components you want to install. Additional packages can always be installed directly from R at a later time. 1.2 Loading and installation of R packages Every function in R is in a package, and packages come with documentation. In addition to those packages included in the initial installation, R comes with several useful contributed packages. You can view the packages available for installation by entering the command library(). Type

>library() To check the functions available on a certain package, type for e.g. >library(help= stats ) will open a help window containing one-line descriptions of all functions in the stats package. When you want to do some specific tasks, for example Analysis of dose-response curves, you will need to install the package that does the intended tasks. In this case you install drc package. The easiest way to install an additional package (eg. drc) is through the Packages menu of the R graphical users interface (RGUI): From the menu select Packages ->Install package(s). A window opens asking you to pick a CRAN mirror site; choose the one nearest you (for our case, its UK- st-andrews); after this, a window will open with the various packages that are available on CRAN. Select the package that you want to install. After selection, click the OK button and the package will be installed (see Figure below). It s not enough to just install the package. You have to load it in memory to make it available for use. You accomplish this by entering the command library( nameofpackage ) at the R console, where nameofpackage is replace with drc for our case type in >library(drc) or from the menu bar packages->load package -> drc

Below is the figure Notice that there is an error message (highlighted). The reason is that drc requires some other package to have been installed for it to run. Here, plotrix is one of them in addition to lattice, MASS and nlme. You will therefore need to install plotrix. You accomplish this using any one of the two procedures of installing packages covered above. In general a good number of packages will not work singly and will require other packages to have been installed. This will be clear from the messages whenever you attempt to load a package and therefore be on the watch. To see the packages currently loaded into memory, type in >search() 1.3 Running the Software To run R click on Start -> All programs -> R-3.1.2 The R icon was created by the setup program during installation. What appears when R is started is called R Graphical Users Interface (RGUI). R issues a prompt where it expects the user to issue a command. The default prompt is (see Figure below).

When R starts you will see a window called the RConsole. This is where you type your commands and see the text results. (Graphs appear in a separate window.) First thing that appears is the version number of R and the date of the version. Warning: some packages work only with the recent versions of R. 1.4 Changing your workspace The first thing you probably want to check is your working directory. You can find this from R by issuing the command getwd() at the R prompt. To change the directory type in >setwd( c://rcourse ) (this will change the directory to data on drive c) or from the menu click on File -> Change dir

1.5 Getting help in R and also online help Online documentation for most of the functions and variables in R exists and can be printed on screen. The easiest way for getting help in R is to click on the Help button on the toolbar of the R general user interface (RGUI). R comes with several official manuals. The following manuals for R are downloadable as PDF files or can be directly browsed as HTML: An Introduction to R, The R language definition, Writing R Extensions, R Data Import/Export, R Installation and Administration, R Internals and The R Reference Index and FAQs. These should be your primary source of information. You should also know about the help function, which opens a help window. This function can be called with arguments to obtain help about specific features of R, for example >help(write.table). A shortcut for help on a topic is a question mark followed by the topic as in >?plot. You obtain the screen below

other times, you only know the subject for which you want help and not the function (eg. anova). In this case use the help.search function and enclose your query with double quotes as follows; >help.search( anova ) or from the menu bar Help->Search help. (enter the anova in the Question dialogue box) The find function tells us what package the object or item you are looking for is contained. For example if you want to find plot, you type; >find( plot ) (remember double quotes on plot) When you use find function, the item that you are looking for must be a function in one of the installed packages and also unique. If you know the name of a package and you need further information concerning the package, you type help(nameofpackage). For example I know there is a package called stats and I want more information about it. At the R console type >help(stats) (and select index to get further details on the package) (see Figures below).

1.6 Importing data We usually measure or observe more than one attribute from a study unit also called a sampling unit. Therefore we organise data sets into collections of variables (vectors). In R, such collections are called data frames in R. You generate a data frame by combining variables whereby each variable becomes a separate column. In order that a data frame to represents the data properly, the sequence in which observations appear in the vectors (variables) must be the same for each vector and each vector should have the same number of observations. For example, the first observations from each of the vectors to be included in the data frame must represent observations collected from the same sampling unit. First, recall that R uses the working directory (or the startup directory). Your data file must be located in the working directory for it to be accessible. Find out what is your working directory and change it if necessary. Use getwd() and setwd() commands. If the file you want to read is not in the working directory, you will need to specify it s complete path. In excel, you can create a comma separated values file (csv). To read a csv file, use the command read.csv. Suppose we have a csv file named Spatial located at c:\rworkshop\ directory. The data will appear as spreadsheet with rows as cases and columns as variables. The columns will have names equal to those in the header of the text datafile. Cases will equal total number of lines excluding header. Then to read it into R, issue the command >mydata<-read.csv(file="c://rworkshop/spatial.csv", header = TRUE) >mydata # List the data for visualization If you want to import a spss file, you need the package foreign >library(foreign) >read.spss("spatial.sav", to.data.frame=t)->data If you want to export your R dataset into excel for viewing/editing, you use the write.table

(for a text file) or write.csv (for a csv file) commands >write.csv(mydata, file="c://rworkshop//csvmdata"). 2. IS SPATIAL MEMORY AGE-RELATED? There is a commonly held belief that the younger you are the more easily you can absorb new material. In fact we are used to parents or grandparents being forgetful having a senior moment. In order to investigate this for a particular kind of memory, spatial, an investigation has been carried out to test the spatial memory of two groups of people, designated as Elderly (over 65) and Young (20-25). In the test, 18 objects were arranged randomly on a 10x 10 grid. Participants were allowed to examine the positions of the objects for as long as they liked and were subsequently asked to recall these positions by replacing the objects on the grid. Their study times and two measures of performance the number positioned correctly and the error in positioning - are recorded. We analyse the dataset Spatial.