18. Menu: RStudio - Preferences My configuration
Configure CRAN mirror
19. Comma Separated Values
Use .CSV
if possible
http://www.edrugsearch.com/edsblog/cvs-takes-on-wal-marts-generic-drug-prices-with-a-gimmicky-twist/#.UEfft0J8z0d
30. http://www.philipcoppens.com/matrixconstructs.html
We will use
publicly available
data
http://www.hsph.harvard.edu/faculty/miguel-
hernan/files/nhefs_book.xls
http://www.hsph.harvard.edu/faculty/miguel-hernan/causal-inference-book/
31. install.packages(“gdata”, dep = T)
library(gdata)
read.xls(“file.xls”)
Perl configuration necessary on Win
http://cran.r-project.org/web/packages/gdata/INSTALL
32. install.packages(“XLConnect”, dep = T)
library(XLConnect)
readWorksheet(loadWorkbook(“file.xls”),
sheet=1)
Define a function for simplicity
my.read.xls <- function(file) readWorksheet(loadWorkbook(file), sheet = 1)
my.read.xls(“file.xls”)
install.packages("XLConnect", type = "source") on Mac
33. To install a package
package name here
install.packages(“package”,
dep = T)
short for TRUE
short for dependencies
34.
35. To load a package
package name here
library(package)
double quote “” can be omitted