You are on page 1of 12

R

2015/03/03

Notation and naming

File names
Object names

Organisation

Commenting
guidelines

Syntax

Spacing
Curly braces
Line length
Indentation
Assignment

http://adv-r.had.co.nz/Style.html

In R, the fundamental unit of shareable code is


the package.
A package bundles together code, data,
documentation, and tests, and is easy to share
with others.
As of January 2015, there were over 6,000
packages available on the
Comprehensive R Archive Network, or CRAN,
the public clearing house for R packages.
3

Frequently Used Tools


Operation
Pull-down
menus

Programmingbased

Open Source Commercial


OpenOffice
Google Docs
Spreadsheet

SPSS
Excel

Stata
SAS

HANDS-ON TUTORIALS

use R! aRe
you suRe?
NodeXL
and
Super R logo
Source: www.redbubble.com/

R for Web Data Analysis


Networ
k
Analysi
s

R packages

igraph, Statnet,
Rsiena

Spatial
Analysis

http://cran.rproject.org/web/views/Spat
ial.html

Sp, Spatial,
OpenStreetMap
, RgoogleMaps

Temporal
Analysis

http://cran.r-project.org/w
tseries, forecast, urca,
eb/views/TimeSeries.html
wavelets, SpatioTemporal
http://cran.rproject.org/web/views/Spat
ioTemporal.html
http://cran.r-project.org/
tm, Rweka, openNLP, word
web/views/NaturalLanguagePcloud, topicmodels, RTex
rocessing.html
tTools,
sentiment,
http://cran.r-project.org/
Nnet, rpart,
trees, ReadM
party,
e
web/views/MachineLearning. randomForest, lasso2, gbm

Text Mining
Machine
Learning

html

, bst, e1071, kernlab, Bay


esTree,
Rgp, arules, frbs, rattle
7

came, I saw,

and I walked away?


Picture: Gareth Jenkins/Solent
http://www.telegraph.co.uk/news/picturegalleries/picturesoftheday/8561204/Pictures-of-the-day-7-June-2011.html?image=6

Figure from the movie Daddy Day Care (2003)


http://img0.joyreactor.com/pics/post/gif-eddie-murphy-reaction-gifs-party-394848.gif

Plunge into
the water!
8

HANDS-ON!

Let's

ock

Demo 1. Software
Installation

Download and install R, Rstudio, and


NodeXL
http://cran.r-project.org/

https://www.rstudio.com/ide/

Learn
the basics of R
http://nodexl.codeplex.com/
http://tryr.codeschool.com/

More information
http://www.rstudio.com/training/online.html
http://joe11051105.gitbooks.io/r_basic/content
10

Demo1.R basics

# get work directory


getwd()
setwd("E:/github/ergm/") # modify here to set
your work directory

http://chengjun.github.io/web_data_analysis/demo1_install_softwares/
11

Demo2. Generate the Network

R script http://chengjun.github.io/web_data_analysis/demo2_simulate_networks/
install.packages("igraph")
library(igraph)
size = 50
g = graph.tree(size, children = 2); plot(g)
g = graph.star(size); plot(g)
g = graph.full(size); plot(g)
g = graph.ring(size); plot(g)
g = connect.neighborhood(graph.ring(size), 2); plot(g)
g = erdos.renyi.game(size, 0.1)
# small-world network
g = rewire.edges(erdos.renyi.game(size, 0.1), prob = 0.8 ); plot(g)
# scale-free network
g = barabasi.game(size) ; plot(g)
12

You might also like