Vous êtes sur la page 1sur 15

Getting Started With R

US 603 Research Methods in Urban Science


13th January, 2016
Installing R

Open cran.r-project.org
The Comprehensive R Archive
Network

Download the version for


your system
Installing R
Installing R
Installing R
Installing R
The R GUI
File->>> New script
Nuts and Bolts
<- is the assignment operator
R has five basic or atomic classes of objects:
character
numeric (real numbers)
integer
complex
logical (True/False)
Symbol Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
Modulo (estimates remainder
%%
in a division)
^ Exponential
Nuts and Bolts Creating Vectors
names, dimnames c() function is used to create vectors
dimensions (e.g. matrices, arrays)
class (e.g. integer, numeric)
length
other user-defined attributes/metadata

Defining matrices
Creating Lists
Importing Data into R
Setting working directory

read.table, read.csv, for reading tabular data


readLines, for reading lines of a text file
source, for reading in R code files (inverse of dump)
dget, for reading in R code files (inverse of dput)
load, for reading in saved workspaces
unserialize, for reading single R objects in binary form
Importing Data into R
D <- read.table(path,sep=,,header=TRUE)
Basic Descriptives
hist(data$X4W) hist(data$X4W,main="Frequency of car ownership")
Basic Descriptives
> boxplot(d$HHInc)
> boxplot(d$HHInc,main= "HH Income variation",ylab="HH Income)
Basic Descriptives
> plot(d$HHInc,d$X4W,xlab="HH Income",ylab="No. of four wheelers")
Resources/ References
R Programming for Data Science- Roger D. Peng (http://leanpub.com/rprogramming)

An Introduction to R- Notes on R: A Programming Environment for Data Analysis and Graphics - W. N.


Venables, D. M. Smith and the R Core Team

> message<- "Thank You"


> message
[1] "Thank You"

Vous aimerez peut-être aussi