Data Analysis
Published:
This post covers Data Analysis using R.
Download:
- R from http://cran.r-project.org/
- RStudio from http://rstudio.com
Resources
- An Introduction to Statistical Learning, https://www.statlearning.com
Introduction
x <- 2
y <- 3
print(x+y)
## [1] 5
# Help
?install.packages
help("install.packages")
# Install Packages
install.packages("rafalib") # Rafael A Irizarry
install.packages("downloader")
# Load Package using library()
library(rafalib)
library(downloader)
getwd()
setwd("~/Downloads/R")
getwd()
# Download femaleMiceWeights.csv from https://github.com/genomicsclass/dagdata/tree/master/inst/extdata by clicking the file and then Raw and then right click to save as
# Read File
dat <- read.csv("data/femaleMiceWeights.csv")
# Download within R
library(downloader)
url <- "https://raw.githubusercontent.com/genomicsclass/dagdata/master/inst/extdata/femaleMiceWeights.csv"
filename <- "data/femaleMiceWeights.csv"
download(url, destfile=filename)
dat <- read.csv("data/femaleMiceWeights.csv")
#Install packages from GitHub
# Windows should start R as administrator
# Windows also install Rtools
install.packages("devtools")
# load packkage
library(devtools)
# install package from github
install_github("genomicsclass/dagdata")
# Get the File from system
#extracts the location of package
dir <- system.file(package="dagdata")
list.files(dir)
#external data is in this directory
list.files(file.path(dir,"extdata"))
filename <- file.path(dir,"extdata/femaleMiceWeights.csv")
dat <- read.csv(filename)