worksheet-1.R 841 Bytes
Newer Older
Zheng Liu's avatar
Zheng Liu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
## Editor

vals <- ...

vals <- seq(...,
  ...)

## Load Data

storm <- read.csv(...)

storm <- read.csv(
  ...,
  ...)

## Lists

x <- list('abc', 1:3, sin)

## Factors

education <- ...(
  c('college', 'highschool', 'college', 'middle', 'middle'),
  ... = c('middle', 'highschool', ...))

## Data Frames

... <- c(32000, 28000, 89000, 0, 0)
... <- data.frame(...)

## Names

...(df) <- c(...)

## Subsetting ranges

days <- c(
  'Sunday', 'Monday', 'Tuesday',
  'Wednesday', 'Thursday', 'Friday',
  'Saturday')
weekdays <- ...
...

## Functions

function(...) {
  ...
  return(...)
}

## Flow Control

first <- function(dat) {
  ... {
    result <- dat[[1]]
  } ... {
    result <- dat[1, ]
  }
  return(result)
}

## Distributions and Statistics

...(n = 10)

x <- rnorm(n = 100, ... = 15, sd = 7)
y <- ...(n = 100, ... = 20, prob = .85)