Publications by Daniel Lee

Document

25.06.2024

# Load packages # Core library(tidyverse) library(tidyquant) Functions When should you write a function? # For reproducible work set.seed(1234) # Create a data from df <- tibble::tibble( a = rnorm(10), b = rnorm(10), c = rnorm(10), d = rnorm(10) ) # Re-scale each Function df$a <- (df$a - min(df$a, na.rm = TRUE)) / (max(d...

274 sym R (2595 sym/24 pcs)

Apply to your Data 11 FIN3100 DAT3000

24.06.2024

Import your data data <- read_excel("../00_data/MyData.xlsx") data(flights) flights %>% skimr::skim() Data summary Name Piped data Number of rows 336776 Number of columns 19 _______________________ Column type frequency: character 4 numeric 14 POSIXct 1 ________________________ Group variables None Variable type: character skim_variab...

528 sym 4 tbl

Code Along 11

24.06.2024

# Load package library(tidyverse) library(tidyquant) Introduction When should you write a function df <- tibble::tibble( a = rnorm(10), b = rnorm(10), c = rnorm(10), d = rnorm(10) ) # Rescale ach colum df$a <- (df$a - min(df$a, na.rm = TRUE)) / (max(df$a, na.rm = TRUE) - min(df$a, na.rm = TRUE)) df$b <- (df$b - min(df$b, na.rm = TRUE)...

281 sym R (2436 sym/25 pcs)

Publish Document

21.06.2024

# Load packages # Core library(tidyverse) library(tidyquant) Goal Calculate and visualize your portfolio’s beta. Choose your stocks and the baseline market. from 2012-12-31 to present 1 Import stock prices #choose stocks symbols <- c("NFLX", "TSLA", "GOOG", "COST") prices <- tq_get(x = symbols, from = "2012-12-31", ...

788 sym R (3742 sym/18 pcs) 1 img

Apply to your Data 10

19.06.2024

# Load packages # Core library(tidyverse) library(tidyquant) Goal Calculate and visualize your portfolio’s beta. Choose your stocks and the baseline market. from 2012-12-31 to present 1 Import stock prices symbols <-c("NVDA", "MSFT", "TSLA", "AMS") prices <- tq_get(x = symbols, get = "stock.prices", from ...

1372 sym R (3261 sym/17 pcs) 1 img

Apply to your Data 10

19.06.2024

Import your data data <- read_excel("../00_data/MyData.xlsx") Chapter 15 Create a factor Modify factor order Make two bar charts here - one before ordering another after Brand_summary <- data %>% group_by(Brand) %>% summarise( Year = mean(Year, na.rm = TRUE), Mileage = mean(Mileage, na.rm = TRUE), n = n() ) Brand_summary ## # ...

288 sym 2 img

Document

19.06.2024

# Load packages # Core library(tidyverse) library(tidyquant) Goal Collect individual returns into a portfolio by assigning a weight to each stock five stocks: “SPY”, “EFA”, “IJS”, “EEM”, “AGG” from 2012-12-31 to 2017-12-31 1 Import stock prices #choose stocks symbols <- c("SPY", "EFA", "IJS", "EEM", "AGG") prices <- tq_get(...

481 sym R (4391 sym/19 pcs) 2 img

Code Along 10

19.06.2024

# Load package library(tidyverse) library(tidyquant) library(readr) library(janitor) library(lubridate) library(nycflights13) Chapter 15 Introduction Creating factors General Social Survey gss_cat ## # A tibble: 21,483 × 9 ## year marital age race rincome partyid relig denom tvhours ## <int> <fct> <int> <fct> ...

460 sym R (8663 sym/50 pcs) 4 img

Code Along 10

19.06.2024

# Load packages # Core library(tidyverse) library(tidyquant) library(scales) library(ggrepel) library(scales) Goal Collect individual returns into a portfolio by assigning a weight to each stock five stocks: “SPY”, “EFA”, “IJS”, “EEM”, “AGG” from 2012-12-31 to 2017-12-31 1 Import stock prices symbols <-c("SPY", "EFA", "IJS", ...

476 sym R (3969 sym/18 pcs) 2 img

Document

18.06.2024

# Load packages # Core library(tidyverse) library(tidyquant) Goal Collect individual returns into a portfolio by assigning a weight to each stock five stocks: “SPY”, “EFA”, “IJS”, “EEM”, “AGG” from 2012-12-31 to 2017-12-31 1 Import stock prices #choose stocks symbols <- c("SPY", "EFA", "IJS", "EEM", "AGG") prices <- tq_get(...

451 sym R (4926 sym/20 pcs) 3 img