Skipping install of 'conflicted' from a github remote, the SHA1 (321d77ce) has not changed since last install.
Use `force = TRUE` to force installation
conflicted::conflicts_prefer(dplyr::filter)
[conflicted] Will prefer dplyr::filter over any other package.
# the URL of our data on GitHubgithub_url <-"https://raw.githubusercontent.com/t-emery/sais-susfin_data/main/datasets/etf_comparison-2022-10-03.csv"# read the data from GitHubblackrock_esg_vs_non_esg_etf <- github_url |>read_csv() |># select the four columns we will use in our anlaysis hereselect(company_name:standard_etf)
Rows: 537 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): ticker, company_name, sector, esg_uw_ow
dbl (7): esg_etf, standard_etf, esg_tilt, esg_tilt_z_score, esg_tilt_rank, e...
lgl (3): in_esg_only, in_standard_only, in_on_index_only
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# use dplyr::glimpse() to get an overview of our datablackrock_esg_vs_non_esg_etf |>glimpse()
blackrock_esg_vs_non_esg_etf_long <- blackrock_esg_vs_non_esg_etf |># we'll learn a lot more about long data & pivot_longer() in future weeks. pivot_longer(cols =contains("etf"), names_to ="fund_type", values_to ="weight") |># case_when() is like an extended "if else"mutate(fund_type =case_when(fund_type =="esg_etf"~"ESG ETF (ESGU)", fund_type =="standard_etf"~"Standard ETF (IVV)"))blackrock_esg_vs_non_esg_etf_long
# A tibble: 1,074 × 4
company_name sector fund_type weight
<chr> <chr> <chr> <dbl>
1 PRUDENTIAL FINANCIAL INC Financials ESG ETF (ESGU) 0.537
2 PRUDENTIAL FINANCIAL INC Financials Standard ETF (IV… 0.106
3 GENERAL MILLS INC Consumer Staples ESG ETF (ESGU) 0.552
4 GENERAL MILLS INC Consumer Staples Standard ETF (IV… 0.151
5 KELLOGG Consumer Staples ESG ETF (ESGU) 0.453
6 KELLOGG Consumer Staples Standard ETF (IV… 0.0592
7 AUTOMATIC DATA PROCESSING INC Information Technology ESG ETF (ESGU) 0.649
8 AUTOMATIC DATA PROCESSING INC Information Technology Standard ETF (IV… 0.312
9 ECOLAB INC Materials ESG ETF (ESGU) 0.441
10 ECOLAB INC Materials Standard ETF (IV… 0.118
# ℹ 1,064 more rows
blackrock_esg_vs_non_esg_etf_long %>%#sets the threshold of companies to those with 1% or greater weightfilter(weight >=1L & weight <=7L) %>%ggplot() +aes(#sets x axis as weight of fund and y axis as the company name#creates a legend for the colour and the size x = weight,y = company_name,colour = fund_type,size = weight ) +geom_point(shape ="circle") +scale_color_manual(values =c(`ESG ETF (ESGU)`="#2BD160",`Standard ETF (IVV)`="#646974") ) +#adds the titles for the axes and the title/author labs(x ="Weight of Fund",y ="Company Name ",title ="ESG Funds vs. Traditional Funds (Non ESG) ",caption ="Niki Linganur " ) +#changes theme colour to green/bluetheme_minimal()
Through the chart we created, we can observe that in most cases the traditional funds are weighted more than or very close to the ESG funds for the same company. The instances where the ESG fund seems to be weighted more, seem to occur in the case where no traditional fund is present (potentially indicating missing data for that company).
c) Making own charts with Esquisse
Chart 1
ggplot(blackrock_esg_vs_non_esg_etf) +#sets the x value as the sector of the fund and y as the number of ESG ETFS aes(x = sector, y = esg_etf) +#changes the colour to purple geom_col(fill ="#440154") +labs(#Renames the axises and adds title/author x ="Sector ",y ="Number of ESG ETF's ",title ="Number of ESG ETF's in Each Sector",caption ="Niki Linganur " ) +#changes the theme ggthemes::theme_pander()
This chart attempts to view which sectors tend to have the highest concentration of ESG ETFs. Through looking at this chart we can gather that Information Technology (IT) has the greatest ESG-oriented ETFs and that the materials sector has the least.
Chart 2
ggplot(blackrock_esg_vs_non_esg_etf) +#sets the x value as the sector of the fund and y as the number of traditional ETFS aes(x = sector, y = standard_etf) +#Changes colour to red geom_col(fill ="#B22222") +labs(#Renames the axises and adds title/author x ="Sector ",y ="Number of Traditional EFT's ",title ="Number of Traditional EFT's in Each Sector",caption ="NIki Linganur " ) +#changes the theme theme_gray()
This chart attempts to answer the inverse question, of which sectors tend to have the highest EFTS (to see if the materials sector just tends to have fewer ETFs than other sectors). Through this chart, we can confirm that materials do indeed have the least ETFs, leading us to conclude that perhaps the ESG EFTs are not allocated by sector.
There is an additional shape line added to this ggplot2 code to allow us to see each point with better precision.
Chart 2
ggplot(blackrock_esg_vs_non_esg_etf) +aes(x = esg_etf, y = standard_etf, colour = sector) +geom_point(shape ="circle", size =1.5) +geom_smooth(span =0.91) +scale_color_hue(direction =1) +# format the axes to make the units clearscale_x_continuous(trans ="log10") +scale_y_continuous(trans ="log10") +#change the theme theme_minimal()
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
The span of the line is changed here to ensure better clarity of the point readability.
Chart 3
ggplot(blackrock_esg_vs_non_esg_etf) +aes(x = esg_etf, y = standard_etf) +#change the size and colourgeom_point(shape ="circle", size =1.5, colour ="#7B1494") +#change the size and colourgeom_smooth(span =0.75, color ="yellow") +# format the axes to make the units clearscale_x_continuous(trans ="log10") +scale_y_continuous(trans ="log10") +#label the axes to clarify x and y titles labs(x ="ESG ETF", y ="Standard ETF") +theme_minimal()
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
The downloaded binary packages are in
/var/folders/yd/c2zm5hrx3z9f72991hsqsbqh0000gn/T//RtmpSnqMlr/downloaded_packages
# librarylibrary(ggplot2)# plot and read data ggplot(data=blackrock_esg_vs_non_esg_etf, aes(x = esg_etf, y = standard_etf, color = sector)) +geom_point() +geom_rug(col="steelblue", alpha=0.8, size=6.5)
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
This chart tells us how concentrated the data is in terms of sector. That is, it tells us how many ETF’s (both ESG and Traditional) are from which sector.
The downloaded binary packages are in
/var/folders/yd/c2zm5hrx3z9f72991hsqsbqh0000gn/T//RtmpSnqMlr/downloaded_packages
install.packages("readr") # Add this line to install the readr package
The downloaded binary packages are in
/var/folders/yd/c2zm5hrx3z9f72991hsqsbqh0000gn/T//RtmpSnqMlr/downloaded_packages
library(ggbeeswarm)library(ggplot2)library(readr) # Add this line to load the readr packagegithub_url <-"https://raw.githubusercontent.com/t-emery/sais-susfin_data/main/datasets/etf_comparison-2022-10-03.csv"# Read the data from GitHubblackrock_esg_vs_non_esg_etf <-read_csv(github_url)
Rows: 537 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): ticker, company_name, sector, esg_uw_ow
dbl (7): esg_etf, standard_etf, esg_tilt, esg_tilt_z_score, esg_tilt_rank, e...
lgl (3): in_esg_only, in_standard_only, in_on_index_only
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Create the ggplotggplot(blackrock_esg_vs_non_esg_etf, aes(esg_etf, sector)) +geom_quasirandom(groupOnX =FALSE)
Orientation inferred to be along y-axis; override with
`position_quasirandom(orientation = 'x')`
This chart tells us which sectors the ESG ETF’s are enclosed in. This data is helpful to see what the correlation might be between sectors and ESG ETF prevalence to see if one type of sector might be more conducive to ESG ETF creation.