Skip to content

Instantly share code, notes, and snippets.

@Nicktz
Last active January 4, 2019 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nicktz/301c55763feb214fd0bbbfe939281bce to your computer and use it in GitHub Desktop.
Save Nicktz/301c55763feb214fd0bbbfe939281bce to your computer and use it in GitHub Desktop.
# Example created with datapasta
library(tidyverse)
library(lubridate)
library(tbl2xts)
df <-
bind_cols(
date = as.Date(c("2018-01-01", "2018-01-02", "2018-01-03", "2018-01-04", "2018-01-05", "2018-01-06", "2018-01-07", "2018-01-08", "2018-01-09", "2018-01-10", "2018-01-11", "2018-01-12", "2018-01-13", "2018-01-14", "2018-01-15", "2018-01-16", "2018-01-17", "2018-01-18", "2018-01-19", "2018-01-20")),
tibble::tribble(
~A_Shares, ~X_Shares, ~C_Shares, ~A_Price, ~X_Price, ~C_Price,
15L, 21L, 16L, 200L, 100L, 78L,
15L, 21L, 16L, 202L, 102L, 77L,
15L, 21L, 16L, 205L, 103L, 74L,
15L, 21L, 16L, 201L, 106L, 73L,
15L, 21L, 16L, 203L, 107L, 71L,
15L, 21L, 16L, 198L, 108L, 70L,
15L, 21L, 16L, 199L, 105L, 68L,
15L, 21L, 16L, 205L, 106L, 69L,
15L, 21L, 16L, 209L, 110L, 71L,
15L, 21L, 16L, 208L, 115L, 68L,
15L, 21L, 16L, 206L, 112L, 65L,
15L, 21L, 16L, 205L, 116L, 64L,
15L, 21L, 16L, 202L, 110L, 66L,
15L, 21L, 16L, 204L, 108L, 61L,
15L, 21L, 16L, 206L, 105L, 60L,
15L, 21L, 16L, 209L, 106L, 58L,
15L, 21L, 16L, 212L, 110L, 57L,
15L, 21L, 16L, 215L, 112L, 56L,
15L, 21L, 16L, 214L, 113L, 54L,
15L, 21L, 16L, 219L, 115L, 52L
)
)%>% mutate_if(is.integer, as.numeric)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment