Skip to content

Instantly share code, notes, and snippets.

@mcdlee
Created May 1, 2017 15:35
Show Gist options
  • Save mcdlee/14f8edac643ee3e8e7165b9d124384bb to your computer and use it in GitHub Desktop.
Save mcdlee/14f8edac643ee3e8e7165b9d124384bb to your computer and use it in GitHub Desktop.
x <- 1:15
y <- x^2
d <- data.frame(x, y) # 另外一種建立 data.frame 的方法
d
dy <- diff(y)
dy <- c(NA, dy) #add a blank NA as the first element
d <- cbind(d, dy)
d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment