# ---------------------------------------------- # # ----- Introduction to R: Getting Started ----- # # ---------------------------------------------- # # # INSTRUCTOR: Chris Fariss # # Copyright (c) 2012, under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. # For more information see: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ # All rights reserved. # # --------------------- # # ----- install R ----- # # --------------------- # # # download R here: cran.r-project.org/ # # # open the .R file using any text or source code editor such as: # TextEdit, emacs, Aquamacs, notepad++ , or Xpad # # # set the working directory to the folder containing the data files # # # the set working directory command in R is setwd() # type ?setwd for help documentation # # to set the path type into R: # # setwd("PATH_NAME") # # where PATH_NAME is the path to the folder with the data # # # ---------------------------- # # ----- install packages ----- # # ---------------------------- # install.packages("foreign") install.packages("MASS") install.packages("igraph") install.packages("sna") # ------------------------- # # ----- load packages ----- # # ------------------------- # library(foreign) library(graph) # --------------------- # # ----- load data ----- # # --------------------- # data <- read.csv("http://polisci2.ucsd.edu/cfariss/code/macro.csv") # note that you can also download the data and load it from your working directory (you need to "un-comment" the line below for it to function) #data <- read.csv("macro.csv") # -------------------- # # ----- end file ----- # # -------------------- #